C语言课程设计报告6

上传人:痛*** 文档编号:68013605 上传时间:2022-04-01 格式:DOC 页数:21 大小:7.99MB
返回 下载 相关 举报
C语言课程设计报告6_第1页
第1页 / 共21页
C语言课程设计报告6_第2页
第2页 / 共21页
C语言课程设计报告6_第3页
第3页 / 共21页
点击查看更多>>
资源描述
C语言课程设计报告班 级: 电气091 学 号: 200909012姓 名: 闫娟玲 指导教师: 张廷荣 评语: 年 月 日1.基本题目1.1 题目有17个人围成一圈,从0号的人开始报数,凡报到3的倍数的人离开圈子,然后再数下去。直到最后只剩下一个人为止。问此人原来的位置是多少号1.2 题目分析流程图:图1 程序流程图1.3 源程序#include void main() int i,k,m,n,num50,*p; printf(enter n”:); scanf(%d,&n); p=num; for(i=0;in;i+) *(p+i)=i+1; /*以1至17为序给每个人编号*/ i=0 /*i为每次循环时的计数变量*/ k=0; /*k为按1,2,3报数时的计数变量*/ m=0; /*m为退出人数*/ while(mn-1) /*当循环体人数比n-1少时(即未退出人数大于1时)执行循环体*/ if(*(p+i)!=0) k+; if(k=3) /*对退出的人的编号置0*/ *(p+i)=0; k=0; m+; i+; if(i=n) /*报数到尾后,i恢复0*/ i=0; while(*p=0) p+; printf(n,*p); return 0;1.4 程序的运行结果图2 程序运行结果2.改错题目2.1 改正后程序 #include #include void fun(char *s,int *a,*b) while(*s) If(*s=A&*s=a&*s=z) (*a)+; s+; main() char s100;int upper=0,lower=0; clrscr(); printf(Please a string:);gets(s); fun(s,&upper,&lower); printf(upper=%d lower=%d,upper,lower); 2.2 程序运行结果图名?结果图的说明,解释3.综合题目3.1 题目六 通讯系统管理系统一 问题描述:通过该系统实现对通讯录进行录入,显示,修改,删除,插入,排序,保存等操作的管理。二 功能要求:1.本系统采用一个包含N个数据的结构体数组,每个数据的结构应当包括:编号,姓名,电话号码,地址。2.本系统显示这样的菜单:请选择系统的功能表: g.通讯信息录入 h.通讯信息显示 i通讯信息保存 j.通讯信息删除 k通讯信息修改 l通讯信息查询 (1)按编号查询 (2)按姓名查询 (3)按电话号码查询 m.退出系统3 执行一个具体的功能之后,程序将重新显示菜单。4.将通讯信息保存到文件中。三 算法提示: 1.数据结构:结构体类型数组 2.数据库结构:下表构成该系统的基本数据库。编号姓名电话号码地址Charcharcharchar四 测试数据: 记录数20五 其它:对该系统有兴趣的同学可以在实现上述基本功能后,完善系统的其他功能。3.2 程序的主要功能 实现基本的通讯录数据管理,如:创建新数据文件,添加数据记录,查找数据记录,删除数据记录,显示所有的数据记录,以及数据的排序等等。(分别使用了new_friend(),search_friend(),search1_friend(),search2_friend(),fun(),xian_friend()等函数)。其中数据的查找,数据的删除又可以通过不同的方式如按学号或姓名等进行操作。(文中所有英文都使用time new Romon字体)。主函数的模块图:图名?3.3 各函数的功能 1)new_friend()是将新的内容加入到通讯录中 ,对进行其它的函数提供条件。 2)search_friend(),search1_friend(),search2_friend()都是用于查找的函数,且其各功能都按照不同的条件进行查找。 3)xian_friend()是对所有存在的通讯录进行查看。 调用函数流程图: 1 通讯信息录入: 图名?2 通信信息显示 3 通信信息保存4 通信信息删除 5 通信信息修改 6 按姓名查询 7 按编号查询8 按电话号码查询3.4 源程序#include#includestruct friends_listchar bian_hao20;char name20;char telephone20;char di_zhi20;int count=0;void new_friend(struct friends_list friends);void search2_friend(struct friends_list friends,char *di_zhi);void search1_friend(struct friends_list friends,char *bian_hao);void search_friend(struct friends_list friends,char *name);void change(friends(friendsi,int n);void writeto text(struct friends_list friends,int n);int delete_friend_record(struct friends_list friends,int n);void fun();void xian_friend(struct friends_list friends);int main(void)char choice;char bian_hao20,name20,telephone20,di_zhi20;struct friends_list friends50;doprintf(g.xin_xi_lu_ru:n);printf(h.xin_xi_xian_shi:n);printf(i.xin_xi_bao_cun:n);printf(j.xin_xi_shan_chu:n);printf(k.xin_xi_xiu_gai:n);printf(l.xin_xi_cha_xun:n);printf(m.tui_chu_xi_tonng:n);printf(xuan_ze_gong_neng:n);scanf(%c,&choice);switch(choice)case g:new_friend(friends);break;case h:xian_friend(friends);break;case i:writeto text(friends,count);break;case j:delete_friend_record(friends,count);break;case k:change(friends,count);break;case l:fun ();break;case m:printf(xie xie shi yongn);break;while(choice!=m);return 0;void new_friend(struct friends_list friends)struct friends_list Name;if(count=50)printf(man!n);return;printf(shu_ru_bian_hao:n);scanf(%s,Name.bian_hao);printf(shu_ru_name:n);scanf(%s,Name.name);printf(shu_ru_telephone:n);scanf(%s,Name.telephone);printf(shu_ru_di_zhi:n);scanf(%s,Name.di_zhi);friendscount=Name;count+;void fun()int choice;char name20,bian_hao20,telephone20;struct friends_list friends50;printf(1:an bian_hao cha:n);printf(2:an name cha:n);printf(3:an telephone cha:n);printf(0 exit:n);printf(enter choice:);scanf(%d,&choice);switch(choice)case 1:printf(shu ru bian_hao:);scanf(%s,bian_hao);search1_friend(friends,bian_hao);break;case 2:printf(shu ru name:);scanf(%s,name);search_friend(friends,name);break;case 3:printf(shhu ru telephone:);scanf(%s,telephone);search2_friend(friends,telephone);break;case 0:break;void search_friend(struct friends_list friends,char *name)int j,flag=0;if(count=0)printf(No found person!n);return;for(j=0;jcount;j+)if(strcmp(name,friendsj.name)=0)flag=1;break;if(flag)printf(bian_hao:%st,friendsj.bian_hao);printf(name:%st,friendsj.name);printf(telephone:%st,friendsj.telephone);printf(di_zhi:%st,friendsj.di_zhi);elseprintf(No!);void xian_friend(struct friends_list friends)int i;if(count=0)printf(No prson!);return;for(i=0;icount;i+)printf(bian_hao:%s:name:%s:telephone:%s:di_zhi:%sn,friendsi.bian_hao,friendsi.name,friendsi.telephone,friendsi.di_zhi);void search1_friend(struct friends_list friends,char *bian_hao)int j,flag=0;struct friends_list friend50;if(count=0)printf(No found person!n);return;for(j=0;jcount;j+)if(strcmp(bian_hao,friendj.bian_hao)=0)flag=1;break;if(flag)printf(bian_hao:%st,friendsj.bian_hao);printf(name:%st,friendsj.name);printf(telephone:%st,friendsj.telephone);printf(di_zhi:%st,friendsj.di_zhi);elseprintf(No!);void search2_friend(struct friends_list friends,char *telephone)int j,flag=0;struct friends_list friend50;if(count=0)待添加的隐藏文字内容2printf(No found person!n);return;for(j=0;jcount;j+)if(strcmp(telephone,friendj.telephone)=0)flag=1;break;if(flag)printf(bian_hao:%st,friendsj.bian_hao);printf(name:%st,friendsj.name);printf(telephone:%st,friendsj.telephone);printf(di_zhi:%st,friendsj.di_zhi);elseprintf(No!);void writeto text(struct friends_list friends,int n)struct friends_list friends50;int i=0;FILE *fp;char filename20;printf(tbao cun dao wen jiann);printf(tshu ru yao bao cun de wen jian ming:);scanf(t%s,filename);if(fp=fopen(filename,w)NULL);printf(tda bu kai!n);system(pause);return;fprintf(fp,tong xun lun);fprintf(fp,bian_hao name dian_hua_hao_ma di_zhin);fprintf(fp,n);while(in)fprintf(fp,%-20st%-20st%-20st%-20sn,friendsi.bian_hao,friendsi.name,friendsi.dian_hua_hao_ma,friendsi.di_zhi);i+;fprintf(fp,n);fprintf(fp,gong you %d tiao ji lun);fclose(fp);printf(bao cun cheng gong!n);int delete_friend_record(struct friends_list friends,int n);char s20;int i=0,j;prntf(tshu ru name:);scanf(%s,s);while(strcmp(friendsi.name,s)!=0&in)i+;if(i=0)printf(ttrong xun lu wu!n);return(n);for(j=i;jn;j+)strcpy(friendsj.bian_hao=friendsj+1.bian_hao);strcpy(friendsj.name=friendsj+1.name);strcpy(friendsj.telephone=friendsj+1.telephone);strcpy(friendsj.di_zhi=friendsj+1.di_zhi);friendsj.bian_hao=friendsj+1.bian_hao);printf(cheng gong shan chu!n);return(n-1);void change(struct friends_list friends,int n);char s20;int i=0;printf(dhu ru name:);scanf(%s,s);while(strcmp(friendsi.name,s)!=0&in)i+;if(i=n)printf(bian_hao:);scanf(%s,friendsi.bian_hao);printf(name:);scanf(%s,friendsi.name);printf(telephone:);scanf(%s,friendsi.telephone);printf(di_zhi:);scanf(%s,friendsi.di_zhi);printf(xiu gai cheng gongn:);3.5 程序运行结果1)显示通讯录主菜单界面 2. 显示通讯录信息界面3通讯录保存界面4通讯录删除界面5通讯录修改界面6通讯录查询界面(1)按姓名查询(2)按电话号码查询(3)按编号查询4. 结论与体会 这次的程序设计试验是对我们进入大学以来学习程序设计语言结果的一次大检验。自己动手,自己发现和解决问题。发现了自己的许多不足。平时没有掌握好的知识在这次试验中彻底暴露出来,经过不断思考,不断查阅资料和上机运行,解决其中大部分问题,当然还存在一些问题没有解决。我相信在以后的学习能够解决好他们。但是,收获还是不小的,我不仅对C的操作有了进一步了解,还了解到了程序设计的书写风格及其注释的格式。 当我选择通讯录这个题目时,一开始想运用大量链表及指针来完成,但是在慢慢琢磨之后,觉得这个不一定要用链表,于是改变了变成思路。当然还有不少文件的读写问题,不过还是通过不断的测试之后顺利的解决了。另外一点要说的是这个程序用了很多的循环,因此对于循环的控制要十分小心,有时while和do-while的区别也是十分重要的。 还有一点体会就是,树上和老师教的知识是有限的,我们需要不断靠自己学习,向他人请教,了解和掌握更多的知识,这样我们才能编出更好的C程序。 总体来说,这次的C语言程序课程设计还是比较成功的,虽然最终程序还存在一些不足,但能取得这样的成果我还是比较高兴的。 最后,要感谢学校为我们提供这次课程设计机会,谢谢老师在学习中对我的指导。参考书目1 何钦铭,颜晖.C语言程序设计.北京:高教出版社,2008.
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 成人自考


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!