⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 考试.txt

📁 C语言数据结构源代码
💻 TXT
字号:
#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#define MAX 100

typedef struct node
{
	int data;
	node *next;
}linklist;

void jay(linklist *a,char b)//递归算法
{
	if(a!=NULL)
	{
		if(a->next!=NULL)
		{
			if(a->data==b)
				cout<<"找到"<<endl;
			else
				jay(a->next,b);
		}
		if(a->next==NULL)
		{
			cout<<"找不到"<<endl;
		}
	}
	else
		cout<<"找不到"<<endl;
}
void lee(linklist *a,char b)//非递归算法
{
	linklist *c;
	c=NULL;
	for(int i=0;i<10;i++)
	{
		c->next=a->next;
		if(c->data==b)
			cout<<"找到!"<<endl;
	}
}
void main(void)
{
	char ch;
	char find;
	linklist *head,*s;
	head=NULL;
	cout<<"please enter a charter:"<<endl;
	cin>>ch;
	while(ch!='$')
	{
		s=(linklist *)malloc(sizeof(linklist));
		s->data=ch;
		s->next=head;
		head=s;
		cout<<"please enter a charter:"<<endl;
		cin>>ch;
	}
	cout<<"please enter a char you want to find"<<endl;
	cin>>find;
	jay(s,find);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -