- 1、本文档共5页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实验目的:题目:
#include stdio.h
#include conio.h
#include stdlib.h
#include windows.h
struct node
{
char c;
struct node *next;
};
struct node *head,*tail,*p,*q,*r;
int cut1=0;
void show()
{
printf(\n\n\t\t\t\t欢 迎 使 用!);
printf(\n\n\t\t\t1、加入元素);
printf(\n\n\t\t\t2、输出全部元素和元素个数);
printf(\n\n\t\t\t3、输出特定元素位置);
printf(\n\n\t\t\t4、输出特定位置元素);
printf(\n\n\t\t\t5、在特定位置插入元素);
printf(\n\n\t\t\t6、删除特定位置元素);
printf(\n\n\t\t\t7、删除全部元素);
printf(\n\n\t\t\t0、退出);
printf(\n\n\t\t请输入:);
}
void chu()
{
head=(struct node*)malloc(sizeof(struct node));
head-next=NULL;
tail=head;
}
void add()
{
int n,i;
printf(\t\t\t请输入要加入的元素个数:);
scanf(%d,n);
for(i=0; in; i++)
{
fflush(stdin);
p=(struct node*)malloc(sizeof(struct node));
printf(\t\t\t请输入元素(单个字母),按回车结束:);
scanf(%c,p-c);
tail-next=p;
p-next=NULL;
tail=p;
cut1++;
}
printf(\n\n\t\t加入完成,按任意键返回主菜单!);
getch();
}
void _count()
{
int cut=1;
if(head-next==NULL)
{
printf(\n\n\n\n\n\n\t\t没有元素 ,按任意键返回主菜单!\n\n\n\n\n\n);
getch();
return ;
}
p=head-next;
while(p-next)
{
printf(%c-,p-c);
cut++;
p=p-next;
}
printf(%c\n,p-c);
printf(\t共 有 %d 个 元 素。,cut);
printf(\n\n\t\t输出完成,按任意键返回主菜单!);
getch();
}
void show1()
{
char s;
int cut=0;
fflush(stdin);
printf(请输入要查找的元素:);
scanf(%c,s);
p=head-next;
while(p)
{
cut++;
if(p-c==s)
{
printf(\n\t\t此元素位于链表第%d的位置!,cut);
printf(\n\n\t\t输出完成,按任意键返回主菜单!);
getch();
return ;
}
p=p-next;
}
printf(\n\t\t没有找到该元素!);
printf(\n\n\t\t输出完成,按任意键返回主菜单!);
getch();
}
void show2()
{
int cut=0,t;
printf(请输入你要找的是第几个元素:);
scanf(%d,t);
if(tcut1)
{
printf(\n\t\t没有找到该元素!);
printf(\n\n\t\t输出完成,按任意键返回主菜单!);
getch();
retu
文档评论(0)