- 29
- 0
- 约5.13千字
- 约 5页
- 2017-06-25 发布于湖北
- 举报
实验目的:题目:
#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
您可能关注的文档
- 物流信息管理系统测试用例幻灯片.docx
- 工艺考核办法介绍.doc
- 党课教案1(入党基本程序).docx
- 设备管理概念题详解.doc
- 软件项目管理及安全-稍微总结版.doc
- 系统测试计划模板幻灯片.doc
- 压力容器安全附件校验规程资料.doc
- 美容、美发会员管理系统需求分析.doc
- 传送带传动设计.doc
- 网络实用技术基础试题和答案(一).docx
- 商业航天的融资渠道与风险研究_2026年1月.docx
- 智慧路灯与城市安防联动布控策略研究_2026年1月.docx
- 元宇宙实验室在工科教学中的沉浸效果评估_2026年1月.docx
- 某公司获国际海底管理局许可采矿但环保组织抗议破坏未知生态系统_2026年1月.docx
- 2026年及未来5年市场数据中国网约车行业发展前景预测及投资战略研究报告.docx
- 2026年及未来5年市场数据中国网络零售产业竞争现状及十五五投资动向研究报告.docx
- 2026年及未来5年市场数据中国卫星通信设备行业市场需求与投资战略规划分析报告.docx
- 2026年及未来5年市场数据中国卫星导航市场竞争力分析及投资战略预测研发报告.docx
- 2026年及未来5年市场数据中国网络教育行业前景研究与投资战略研究报告.docx
- 2026年及未来5年市场数据中国微型滤波器行业市场专项调研及投资前景可行性预测报告.docx
最近下载
- 钻井硫化氢考试题及答案.doc VIP
- T/GXAS 845-2024 血液净化专科护士临床培训规范 发布稿.pdf VIP
- 钻井硫化氢考试题及答案.docx VIP
- 2026年硫化氢证考试题库及答案.docx VIP
- 甘肃省临夏市职业能力倾向测验事业单位考试(综合管理类A类)试题附答案.docx VIP
- 硫化氢考试题库及答案.docx VIP
- 银行存款和取款数据流程图.pptx VIP
- 2025年税务人员执法资格练习题练习题库及答案.docx VIP
- 2025年全国税务人员执法资格考试练习题及答案—全国税务系统.docx VIP
- 精品解析:重庆市2024-2025学年高二上学期期末联合检测 化学试题 (原卷版).docx VIP
原创力文档

文档评论(0)