厦门理工数据结构课程设计0907052218.docx

上传人:b****7 文档编号:16464909 上传时间:2023-07-13 格式:DOCX 页数:50 大小:191.81KB
下载 相关 举报
厦门理工数据结构课程设计0907052218.docx_第1页
第1页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第2页
第2页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第3页
第3页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第4页
第4页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第5页
第5页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第6页
第6页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第7页
第7页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第8页
第8页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第9页
第9页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第10页
第10页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第11页
第11页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第12页
第12页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第13页
第13页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第14页
第14页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第15页
第15页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第16页
第16页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第17页
第17页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第18页
第18页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第19页
第19页 / 共50页
厦门理工数据结构课程设计0907052218.docx_第20页
第20页 / 共50页
亲,该文档总共50页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

厦门理工数据结构课程设计0907052218.docx

《厦门理工数据结构课程设计0907052218.docx》由会员分享,可在线阅读,更多相关《厦门理工数据结构课程设计0907052218.docx(50页珍藏版)》请在冰点文库上搜索。

厦门理工数据结构课程设计0907052218.docx

厦门理工数据结构课程设计0907052218

 

《数据结构》

课程设计报告

 

姓名:

刁方圆

学号:

0907052218

班级:

09软2

设计时间:

2010.12.20~2010.12.24

审阅教师:

谢彦麒

课程设计报告

通讯录管理系统

•一、题目内容的描述

通讯录一般包括通讯者的编号、姓名、性别、电话及地址等信息,设计一个通讯录要求实现通讯者的插入、查询、删除、更新、排序操作。

•二、应用程序功能的详细说明

程序主要能实现添加记录、查找记录、删除记录。

•三、输入数据类型、格式和内容限制;

本程序所有数据都可输入字符型。

•四、主要模块的算法描述

生成菜单:

创建结点:

structrecord

{

charname[8];

charsex[20];

charnum[20];

chartel[20];

charaddress[20];

}student[500];

structslnode

{

recorddate;

structslnode*next;

structslnode*prior;

};

利用顺序表储存通讯录信息。

查找函数search():

printf("\n\t\t请输入姓名:

");

scanf("%s",name);

for(inti=a;inext)

{

if(strcmp(name,p->next->date.name)==0)

{

printf…....

记录删除:

for(j=i;j

student[j]=student[j+1];

num--;

创建通讯录:

添加一项记录:

删除操作:

•五、结束语

通过本题的锻炼,让我更加熟悉顺序表的使用了。

顺序表虽然查询比较方便,但在插入删除操作都比较繁琐。

或许还能用链式表做改进。

•六、程序的源代码清单

#include

#include

#include

#include

structrecord

{

charname[8];

charsex[20];

charnum[20];

chartel[20];

charaddress[20];

}student[500];

structslnode

{

recorddate;

structslnode*next;

structslnode*prior;

};

typedefslnode*linklist;

linklistl;

intnum=0;

FILE*fp;

voidmainmenu();

voidsearchmenu();

voidenter();

voidsearch();

voiddisplay();

voidload();

voidsave();

voiddelet();

voidlistinsert();

voidinitlist();

voidmain()

{

initlist();

load();

listinsert();

while

(1)

mainmenu();

}

voidload()

{

if((fp=fopen("student.bin","rb"))==NULL)

{

printf("\n\t\t通讯录文件不存在");

if((fp=fopen("student","wb"))==NULL)

{

printf("\n\t\t建立失败");

exit(0);

}

else

{

printf("\n\t\t通讯录文件已建立");

printf("\n\t\t按任意键进入主菜单");

getch();

return;

}

exit(0);

}

fseek(fp,0,2);

if(ftell(fp)>0)

{

rewind(fp);

for(num=0;!

feof(fp)&&fread(&student[num],sizeof(structrecord),1,fp);num++);

printf("\n\t\t文件导入成功");

printf("\n\t\t按任意键返回主菜单");

getch();

return;

}

printf("\n\t\t文件导入成功");

printf("\n\t\t通讯录文件中无任何纪录");

printf("\n\t\t按任意键返回主菜单");

getch();

return;

}

voidmainmenu()//主菜单

{

charchoic;

system("cls");

printf("\n\t\t***************欢迎进入通讯录系统***************");

printf("\n\t\t******************1-新添纪录******************");

printf("\n\t\t******************2-查找联系人****************");

printf("\n\t\t******************3-删除联系人***************");

printf("\n\t\t******************4-保存退出*****************");

printf("\n\t\t******************5-不保存退出***************");

printf("\n\t\t************************************************");

printf("\n\t\t请选择:

");

choic=getch();

switch(choic)

{

case'1':

enter();break;

case'2':

searchmenu();break;

case'3':

delet();break;

case'4':

save();break;

case'5':

exit(0);

default:

mainmenu();

}

}

voidsearchmenu()//查询菜单

{

charchoic;

system("cls");

printf("\n\t\t*******************查询菜单*******************");

printf("\n\t\t****************1-显示所有********************");

printf("\n\t\t****************2-按姓名查询******************");

printf("\n\t\t****************3-返回主菜单******************");

printf("\n\t\t************************************************");

printf("\n\t\t请选择:

");

choic=getch();

switch(choic)

{

case'1':

display();break;

case'2':

search();break;

case'3':

mainmenu();break;

}

}

voidenter()//添加纪录

{

printf("\n\t\t****************请输入学生信息****************\n");

printf("\n\t\t姓名:

");

scanf("%s",&student[num].name);

printf("\n\t\t性别:

");

scanf("%s",&student[num].sex);

printf("\n\t\t编号:

");

scanf("%s",&student[num].num);

printf("\n\t\t输入电话:

");

scanf("%s",&student[num].tel);

printf("\n\t\t地址:

");

scanf("%s",&student[num].address);

num++;

printf("\n\t\t是否继续添加?

(Y/N):

");

if(getch()=='y')

enter();

return;

}

voiddisplay()//显示所有

{

inti;

system("cls");

if(num!

=0)

{

printf("\n\t\t***************以下为通讯录所有信息************");

for(i=0;i

{

printf("\n\t\t姓名:

%s",student[i].name);

printf("\n\t\t性别:

%s",student[i].sex);

printf("\n\t\t编号:

%s",student[i].num);

printf("\n\t\t电话:

%s",student[i].tel);

printf("\n\t\t地址:

%s",student[i].address);

printf("\t\t");

if(i+1

{

printf("\n\t\t__________________________");

system("pause");

}

}

printf("\n\t\t************************************************");

}

else

printf("\n\t\t通讯录中无任何纪录");

printf("\n\t\t按任意键返回主菜单:

");

getch();

return;

}

voidsave()//写入文件

{

inti;

if((fp=fopen("student","wb"))==NULL)

{

printf("\n\t\t文件打开失败");

}

for(i=0;i

{

if(fwrite(&student[i],sizeof(structrecord),1,fp)!

=1)

{

printf("\n\t\t写入文件错误!

\n");

}

}

fclose(fp);

printf("\n\t\t通讯录文件已保存");

printf("\n\t\t按任意键退出程序\n\t\t");

exit(0);

}

voidlistinsert()//增加一个结点

{

linklists,p=l;

for(inti=0;i

{

s=newslnode;

strcpy(s->date.name,student[i].name);

strcpy(s->date.num,student[i].num);

strcpy(s->date.sex,student[i].sex);

strcpy(s->date.tel,student[i].tel);

strcpy(s->date.address,student[i].address);

s->prior=p->prior;

s->next=p;

p->prior->next=s;

p->prior=s;

p=p->next;

}

}

voidinitlist()

{

l=newslnode;

l->next=l;

l->prior=l;

}

voidsearch()

{

intj=0,a=0;

linklistp=l;

printf("\n\t\t*****************按姓名查找*******************");

charname[8];

printf("\n\t\t请输入姓名:

");

scanf("%s",name);

for(inti=a;inext)

{

if(strcmp(name,p->next->date.name)==0)

{

printf("查询到的信息:

");

printf("\n");

printf("姓名:

");

printf("%s",p->next->date.name);

printf("\n");

printf("编号:

");

printf("%s",p->next->date.num);

printf("\n");

printf("地址:

");

printf("%s",p->next->date.address);

printf("\n");

printf("性别:

");

printf("%s",p->next->date.sex);

printf("\n");

printf("电话:

");

printf("%s",p->next->date.tel);

j++;

}

if(j==0)

printf("\t\t该通讯录没有该人!

");

if((i+1)

{

printf("\n\t\t是否继续查找相同名字的学生信息:

(y/n)");

if(getch()=='y')

{

a=i;

continue;

}

else

return;

}

else

{

printf("\n\t\t按任意键返回主菜单");

getch();

return;

}

}

}

voiddelet()

{

inta=0;

intfindmark=0;

intj;

intdeletemark=0;

inti;

charname[8];

printf("\n\t\t请输入要删除学生姓名:

");

scanf("%s",name);

for(i=a;i

{

if(strcmp(student[i].name,name)==NULL)

{

printf("\n\t\t以下是您要删除的学生纪录:

");

findmark++;

printf("\n\t\t________________________________");

printf("\n\t\t姓名:

%s",student[i].name);

printf("\n\t\t性别:

%s",student[i].sex);

printf("\n\t\t编号:

%s",student[i].num);

printf("\n\t\t电话:

%s",student[i].tel);

printf("\n\t\t地址:

%s",student[i].address);

printf("\n\t\t________________________________");

printf("\n\t\t是否删除?

(y/n)");

if(getch()=='y')

{

for(j=i;j

student[j]=student[j+1];

num--;

deletemark++;

printf("\n\t\t删除成功");

if((i+1)

{

printf("\n\t\t是否继续删除相同姓名的同学信息?

(y/n)");

if(getch()=='y')

{

a=i;

continue;

}

}

printf("\n\t\t是否继续删除?

(y/n)");

if(getch()=='y')

delet();

return;

}

if((i+1)

{

printf("\n\t\t是否继续删除相同姓名的同学信息?

(y/n)");

if(getch()=='y')

{

a=i;

continue;

}

}

}

else

continue;

}

if((deletemark==0)&&(findmark==0))

{

printf("\n\t\t没有该同学的纪录");

return;

}

else

if(findmark!

=0)

{

printf("\n\t\t没有重名信息");

printf("\n\t\t没有该同学的纪录");

return;

}

}

仓库管理系统

•一、题目内容的描述

设计一个仓库管理系统,可以按照顺序和货物名称查询仓库的存储情况,也可以增加或删除货物。

structnode

{

intNO;//商品编号

charname[max];//商品名称

intcount;//商品数量

};

•二、应用程序功能的详细说明

利用链式表存储仓库信息,可以完成简单的排序、查询、插入、删除物品数据。

•三、输入数据类型、格式和内容限制;

数据输入类型商品编号int整型,商品名称char字符,数量用int整型。

•四、主要模块的算法描述

利用链式表定义双结构体定义双节点

Typedefstruct{

charname[10];

intNO;

intcount;

}Store;

typedefstructnode{

Storeelem;

structnode*next;

}In;

储存商品信息,利用菜单函数menu();建立用户界面:

1-数据初始化

2-创建数据表

3-数据插入

4-数据删除

5-数据更新

6-数据查询

7-编号升序

w-数据保存

r-数据读出

0-系统推出(exit)

利用循环创建仓库信息:

for(i=0;i

s=Init();

printf("名称编号数量\n");

scanf("%s",&s->elem.name);

scanf("%d",&s->elem.NO);

scanf("%d",&s->elem.count);

p->next=s;

p=s;

利用交换法排序:

for(p1=head->next;p1->next!

=NULL;p1=p1->next)

for(p2=p1->next;p2!

=NULL;p2=p2->next)

if(p1->elem.NO>p2->elem.NO){

p3->elem=p1->elem;

p1->elem=p2->elem;

p2->elem=p3->elem;

}

实验结果截图:

仓库管理系统:

创建:

插入:

插入之后:

排序(按编号升序):

删除:

删除后:

•五、结束语

仓库管理系统让我再次体验到了链表的操作方便和强大。

•六、程序的源代码清单

#include

#include

#include

#include

#include

#defineSIZE100

typedefstruct{

charname[10];

intNO;

intcount;

}Store;

typedefstructnode{

Storeelem;

structnode*next;

}In;

In*head=NULL;

voidappendInfo();

voidList();

voidmenu(void);

In*Init();

voidStart();

voidInsert();

voidDel();

voidrenew();

voidWsave();

voidRead();

voidSortUp();

voidPreFile();

intmain(){

charselect;

PreFile();

menu();

while((select=toupper(getch()))!

='0'){

system("cls");

switch(select)

{

case'1':

{

Start();system("pause");menu();

break;

}

case'2':

{

appendInfo();system("pause");menu();

break;

}

case'3':

{

Insert();system("pause");menu();

break;

}

case'4':

{

Del();system("pause");menu();

break;

}

case'5':

{

renew();system("pause");menu();

break;

}

case'6':

{

List();system("pause");menu();

break;

}

case'7':

{

SortUp();system("pause");menu();

break;

}

case'W':

{

Wsave();

system("pause");

menu();

break;

}

case'R':

{

Read(

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2