C语言课程设计报告765Word下载.docx
《C语言课程设计报告765Word下载.docx》由会员分享,可在线阅读,更多相关《C语言课程设计报告765Word下载.docx(12页珍藏版)》请在冰豆网上搜索。
{
intn,w1;
voidenter();
voidadd();
voidmodify();
voidbrowse();
voiddeleter();
voidsearch();
do
{
puts("
\t******************************菜单*****************************\t\n\n"
);
\t\t\t\t1.新建联系人"
\t\t\t\t2.添加联系人"
\t\t\t\t3.修改"
\t\t\t\t4.删除"
\t\t\t\t5.浏览"
\t\t\t\t6.查找"
\t\t\t\t7.退出"
\n\n\t***************************通讯录******************************\t\n"
printf("
请选择服务种类(1-7):
[]\b\b"
scanf("
%d"
&
n);
if(n<
1||n>
7)
{w1=1;
getchar();
}
elsew1=0;
}while(w1==1);
switch(n)
case1:
enter();
break;
/*输入模块*/
case2:
add();
/*添加模块*/
附录:
源代码
#defineN50
#include<
stdio.h>
string.h>
structpeople
{charname[20];
charcompany[50];
charnum[15];
charmail[20];
}peop[N];
voidprintf_face()
{printf("
\n\t姓名\t单位\t电话号码\t邮箱\n"
}
voidprintf_one(inti)
\t%s\t%s\t%s\t%s\n"
peop[i].name,peop[i].company,peop[i].num,peop[i].mail);
voidprintf_n(intn)
{intj;
for(j=0;
j<
n;
j++)
{if((j!
=0)&
&
(j%10==0)){printf("
\n\nPressanykeytocontinue...:
"
getchar();
\n\n"
printf_one(j);
}getchar();
intload()
{FILE*fp;
inti;
if((fp=fopen("
file"
"
rb"
))==NULL)
\nCannotopenfile\n"
exit(0);
for(i=0;
!
feof(fp);
i++)
fread(&
peop[i],sizeof(structpeople),1,fp);
fclose(fp);
return(i-1);
intmodify_data(inti,intn)
{intc,w1;
voidinput(inti);
voidmenu();
{puts("
\n修改选项=>
\n\n1).姓名2).单位3).电话号码4).邮箱5).所有数据6).取消并返回"
请选择?
:
c);
if(c>
6||c<
1){puts("
\nChooseerror!
Pleaseagain!
}while(c>
1);
{switch(c)
{case1:
name:
%s"
peop[i].name);
company:
peop[i].company);
case3:
number:
peop[i].num);
case4:
e-mail:
peop[i].mail);
case5:
input(i);
case6:
menu();
\nNow:
\n"
printf_face();
printf_one(i);
\n确定?
\n\n\t1).是2).不,重新修改3).返回不保存[]\b\b"
w1);
}while(w1==2);
return(w1);
voidinput(inti)
{printf_face();
\t"
%s\t%s\t%s\t%s"
voidsave(intn)
wb"
{printf("
for(i=0;
i<
if(peop[i].name[0]!
='
\0'
)
if(fwrite(&
peop[i],sizeof(structpeople),1,fp)!
=1)
filewriteerror\n"
fclose(fp);
voidprintf_back()
intw;
\n\n\t^_^.Successful.^_^\n\n"
Whatdoyouwanttodo?
\n\n\t1).浏览所有\t2).返回:
w);
if(w==1)browse();
elsemenu();
voidmain()
voidmenu()
\t************************菜单************************"
\t\t*******************1.新建联系人*******************"
\t\t*******************2.添加联系人*******************"
\t\t*******************3.修改*******************"
\t\t*******************4.删除*******************"
\t\t*******************5.浏览*******************"
\t\t*******************6.查找*******************"
\t\t*******************7.退出*******************"
\n\n\t********************通讯录*********************"
modify();
deleter();
browse();
search();
case7:
voidenter()
{inti,n;
Howmanypeople(0-%d)?
N-1);
请输入数据:
{printf("
\n输入第%d个记录.\n"
i+1);
if(i!
=0)save(n);
printf_back();
voidadd()
{inti,n,k,t;
n=load();
Howmanypeopledoyouwanttoadd(0-%d)?
N-n-1);
t);
k=n+t;
for(i=n;
k;
i-n+1);
save(k);
voidmodify()
{structpeoples;
inti,n,k,w0=1,w1,w2=0;
{k=-1;
printf_n(n);
\n\nEnternamethatyouwanttomodify!
\nName:
s.name);
if(strcmp(s.name,peop[i].name)==0){k=i;
s=peop[i];
if(k==-1)printf("
\n\n没有记录请重新输入!
}while(k==-1);
printf_one(k);
w1=modify_data(k,n);
if(w1==1){printf("
\n\t^_^.Successful^_^.\n\n是否继续?
\n\n\t1).是2).保存返回\t[]\b\b"
w0);
w2=1;
else
{w0=0;
if(w2==0)peop[k]=s;
if((w0!
=1)&
(w2==1))save(n);
}while(w0==1);
voidbrowse()
{intn;
\t共有%d记录.\n"
n);
\nPressanykeytoback..."
voidsearch()
{intw0,k,i,n,w1,w2;
structpeoples;
请选择查找类别:
1).姓名2).电话号码[]\b\b"
if(w1<
1||w1>
2){printf("
输入错误!
请重新输入!
}while(w2==1);
if(w1==1)
{do
\n\nEnternamethattouwanttosearch!
\nWhatdoyouwanttodo?
\n\t1).继续2).返回菜单[]\b\b"
{do
\n\nEnternumberthattouwanttosearch!
\nNum:
s.num);
if(strcmp(s.num,peop[i].num)==0){k=i;
voiddeleter()
{structpeoples;
inti,n,k,w0,w1;
\n\nEnternamethatyouwanttodelete!
\n\t1).是2).返回[]\b\b"
if(w0==1){peop[k].name[0]='
;
save(n);
}elsebreak;
\n\t^_^.Successful^_^.\n"
\n\t1).继续2).返回[]\b\b"
【设计体会】
通过为期一周的课程设计,我们对《C语言》这门课程有了更深一步的了解。
它是计算机程序设计的重要理论技术基础,在我们信息与计算科学专业的学习中占据着十分重要的地位。
同时也使我们知道,要学好这门课程,仅学习书本上的知识是不够的,还要有较强的实践能力。
因为我们学习知识就是为了实践。
而只有多实践,多编写程序,才能更好的理解与掌握书本上的东西。
运用《C语言》中的算法思想作数据结构,结合C语言基本知识,编写一个通讯录管理系统。
通过完成本课题,进一步熟悉C语言的基本知识,并掌握数据结构的一些基本算法思想,掌握C语言的文件操作(包括从磁盘读入和向磁盘写入内容),进一步熟悉指针的用法,数组的建立运用和函数的调用等。
【参考文献】
朱若愚.数据结构[M].北京:
电子工业出版社,2006.1:
41-65
晋良颍.数据结构[M].北京:
人民邮电出版社,2007.05:
21-45
刘大有.数据结构[M].北京:
高等教育出版社,2006.3:
30-58
赵文静.数据结构与算法[M].北京:
科学出版社,2007.8:
41-64
徐孝凯.数据结构简明教程.[M].北京:
清华大学出版社,2006.04:
102-115
严蔚敏,吴伟民.数据结构(C语言版)[M].北京:
清华大学出版社,2007.4:
39-43
傅清祥,王晓东.数据结构与算法设计[M].北京:
电子工业出版社,2006.3:
31-46
王敬华,林萍,.陈静.C语言程序设计[M].北京:
清华大学出版社,2007.10:
22-39
李云清,杨庆红,揭安全.数据结构(C语言版)[M].北京:
人民邮电出版社,2006.1:
44-67
[10]李春葆.数据结构(C语言版)习题与解析[M].北京:
清华大学出版社,2006.1:
47-55