1、浏览模块流程图1,2,还是3按书名查找模块流程图按作者查找模块流程图插入模块流程图(3)数据结构typedef struct book int sort; char book_name15; char author_name15; int vert_number; char publish_unit15; char publish_time10; int price;B(4).模块设计根据功能需要:源文件函数名功能save()保存input()输入get()获取output()输出book_name通过书名查找author_name()通过作者查找modify()修改delet()删除(5)总
2、体设计思想:(6)调试过程: 测试数据及结果,出现了哪些问题(7)程序有待改进的地方及本次实习的收获和建议(8)源程序清单(主要代码)#includestdlib.hstring.h#define LEN sizeof(struct book)B;B *P,*p1,boo;int num=0,f=0;int save();void input();int get();void output();void book_name();void author_name();void modify();void delet();int main() int re=1,t,j=0; int n,choic
3、e; while(re=1) t=1; system(cls); printf( *n printf( 主菜单 nn 1.录入信息n 2.查看信息n 3.查询信息n 4.删除与修改信息n 5.退出n *n if(j=1) printf(nt选择错误!nt请选择1-5: _bb scanf(%d,&choice); switch(choice) case 1: printf(nt1: 录入信息n input();n t1.返回主菜单;nt 2.退出 ntt请选择: scanf(re); break; case 2:nt2.查看信息n output();nt 1.返回主菜单;nt 2.退出ntt请
4、选择: case 3: while(t=1) printf(nt3.查询信息nnt 请选择查询方式:nt 1.按书名nt 2.按作者名nt 3.其余任意数字键返回主菜单 _bbn); if(n=1) book_name(); else if(n=2) author_name(); else re=1; goto lebel; nt 1.返回上一层;nt 2.返回主菜单;nt 3.退出 nt 请选择:t); if(t=1) system( if(t=2) re=1; if(t=3) re=0; lebel: break; case 4: while(t=1|f=1) nt4.删除与修改信息nnt
5、 请选择:nt 1.删除信息;nt 2.修改信息n t 3.其余任意数字键返回主菜单 _bb delet(); modify(); goto lebe;nt 3.退出 ntt 请选择: if(t=1) if(t=2) re=1; lebe: case 5: re=0; break; default: re=1; j=1; return 0;int save() FILE *fp; int i,n=0,n1=0; if(fp=fopen(book.txt,a+)=NULL) return 0;fprintf(fp,%dn,num); for(i=0;i0) P=(B *)malloc(LEN *
6、 num); for(i=0; fscanf(fp,%d%s%s%d%s%s%dPi.sort,Pi.book_name, Pi.author_name,&Pi.vert_number,Pi.publish_unit,Pi.publish_time,&Pi.price); fclose(fp); return 1; else return 0;void input() int result;tt要录入信息的书籍数量为: _本bb P=(B *)malloc(LEN * num); Pi.sort=i+1;ntNO. %d,Pi.sort); printf(t请按序输入:书名 作者名 分类号 出
7、版单位 出版时间 价格ntt scanf(%s%s%d%s%s%d,Pi.book_name,Pi.author_name,&Pi.vert_number,Pi.publish_unit, Pi.publish_time,& result=save(); if(result=0) t录入信息失败! num = 0; if(result=1) t成功录入信息! num=0; t输入错误!void output() get(); if(get()=1)ntt成功获取信息!nttNO.t%dntt 书名 作者名 序列号 出版单位 出版时间 价格ntt %s %s %d %s %s %d,Pi.boo
8、k_name,Pi.author_name,Pi.vert_number,Pi.publish_unit, Pi.publish_time,Pi.price); else printf( t文件打开错误!void book_name() int tag=0; char ch15;t 请输入书名:scanf(%s,ch); if(get()=0) t无法查询! return; if(strcmp(Pi.book_name,ch)=0)ntt 排列号 书名 作者名 序列号 出版单位 出版时间 价格ntt %d %s %s %d %s %s %dn tag =1; if (tag = 0)n t没有
9、相关信息!void author_name()t 请输入作者名: if(strcmp(Pi.author_name,ch)=0) Pi.author_name,Pi.vert_number,Pi.publish_unit,Pi.publish_time,Pi.price); tag =1; t没有相关信息!void modify() int t,n,i,y=1; int result,z,x; t=get(); if(t=0)n t打开文件错误,无法修改! else if(y=1)nt 您要修改信息的图书排列号为(1-%d): scanf( if(n=1&n=num) for(i=0; if(
10、Pi.sort=n)nt您即将修改以下信息:tt 排列号 书名 作者名 序列号 出版单位 出版时间 价格ntt %d %s %s %d %s %s %d Pi.author_name,Pi.vert_number,Pi.publish_unit, Pi.publish_time,Pi.price);nnt 确认请按1;返回请按2;返回上一层请按3 _bb scanf(x); if(x=1) /p1=&boo;t 您要将信息修改为:tt书名:,Pi.book_name);tt作者名:, Pi.author_name);tt序列号:Pi.vert_number);tt出版单位:,Pi.publis
11、h_unit);tt出版时间:,Pi.publish_time);tt价格: strcpy(Pi.book_name,Pi.book_name); strcpy(Pi.author_name,Pi+1.author_name); Pi.vert_number=Pi+1.vert_number; strcpy(Pi.publish_unit,Pi+1.publish_unit); strcpy(Pi.publish_time,Pi+1.publish_time); Pi.price=Pi+1.price; y=0; z=1; else if(x=2) y=1;z=0; else y=0; f=1
12、; else t输入错误,请重新输入: y=1; while(z=1) result=save();n t修改信息失败! z=0; if(result=1) n t成功修改信息! return;void delet() int t,n,i,j,y=1; int result,z=0,x;n t打开文件错误,无法删除! else while(y=1) nt 您要删除信息的图书排列号为(1-%d): for(i=0; if(Pi.sort=n) printf(nt 您即将删除以下信息: if(x=1) for(j=i;jnum-1;j+) strcpy(Pj.book_name,Pj+1.book_name); strcpy(Pj.author_name,Pj+1.author_name); Pj.vert_number=Pj+1.vert_number; strcpy(Pj.publish_unit,Pj+1.publish_unit); strcpy(Pj.publish_time,Pj+1.publish_time); Pj.price=Pj+1.price; num=num-1; if(x=2) else y=0; f=1; nt删除信息失败! if(result=1) nt成功删除信息!
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1