ImageVerifierCode 换一换
格式:DOCX , 页数:25 ,大小:239.12KB ,
资源ID:10300962      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/10300962.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(借还书信息汇总 课程设计报告.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

借还书信息汇总 课程设计报告.docx

1、借还书信息汇总 课程设计报告 课程设计课程 程序设计基础 题目 借还书信息汇总 院系名称 计算机学院 班 级 计算机科学与技术5班 学生姓名 学号 组 员 指导教师 时 间 2012年2月24日 1 问题要求及任务描述1.1题目要求20借还书信息汇总 问题描述:设有借还书记录文件a.txt,b.txt结构如下:a.txt账号学号图书索引号借书时间1234562008001001TP3452009-1-124232010330002O3.62010-2-3btxt账号学号图书索引号还书时间1234562008001001TP3452009-3-124232010330002O3.62010-3-

2、20要求:1从a.txt和b.txt中读取相关信息存储到两个链表中2以账号、学号、图书索引号为关联合并两个文件,合并后格式如下账号学号图书索引号借书时间还书时间1234562008001001TP3452009-1-12009-3-124232010330002O3.62010-2-32010-3-20存储到链表中3将2生成的链表数据存储到文件中注意:1、a.txt文件中存在与b.txt不匹配项,要求忽略2、b.txt文件中存在与a.txt不匹配项,要求忽略1.2主要任务主要功能:对借还书信息进行汇总、处理。将输入两个文件中的相关信息存储到两个相对应的链表中。合并两个文件的信息,并将信息存储到

3、另一个文件中。对文件建立链表,使链表中的信息为账号、学好、图书索引号、借书时间、还书时间。将生成的链表数据存储到文件中。2 解决问题的主要思路和方法2.1 关键问题合并两个文件。对文件建立链表,并将生成的链表数据存储到文件中。2.2 拟采用解决问题的方法 将文件a.txt和b.txt中的信息复制到文件c.txt。然后对文件c.txt建立链表,保留账号、学好、图书索引号、借书时间、还书时间。借还书信息结构体:struct book char zhanghao8; char num11; char suoyinhao6; char time10; char returntime10; an,bn,

4、cn; struct node char zhanghao8; char num11; char suoyinhao6; char time10; char returntime10; struct node *next; ;调用函数结构:main()head1=insertone(head1); head2=inserttwo(head2); showone(head1); showtwo(head2); 子函数: struct node *insertone(struct node *head1) struct node *inserttwo(struct node *head2) 2.3

5、 主要算法和处理流程图主要算法:主函数: struct node *head; struct node *head1; struct node *head2; head1=insertone(head1); head2=inserttwo(head2); showone(head1); showtwo(head2); head1=loadone(); head2=loadtwo(); hebing(head1,head2); head=loadthree(); showthree(head); 部分子函数:struct node *insertone(struct node *head1)in

6、t i; struct node *p,*q; head1=q=(struct node *)malloc(sizeof(struct node); printf( 欢迎进入借还书信息系统,请输入相关信息n);for(i=0;inext=p; q=p; p-next=0; return head1;struct node *inserttwo(struct node *head2) int i; struct node *p,*q; head2=q=(struct node *)malloc(sizeof(struct node); for(i=0;inext=p; q=p; p-next=0

7、; return head2;void showone(struct node *head1)int i; struct node *temp; temp=head1; printf(a.txtn); fp1=fopen(a.txt,w); for(i=0;in;i+) if(fwrite(&ai,sizeof(struct book),1,fp1)!=1) N Y printf(文件写入数据错误n); fclose(fp1); fp1=fopen(a.txt,r); printf(n账号 学号 图书索引号 借书时间n); for(i=0;inext; fclose(fp1);void sho

8、wtwo(struct node *head2)int i; struct node *temp; temp=head2; printf(b.txtn); fp2=fopen(b.txt,w); for(i=0;in;i+) if(fwrite(&bi,sizeof(struct book),1,fp2)!=1) N Y printf(文件写入数据错误n); fclose(fp2); fp2=fopen(b.txt,r); printf(n账号 学号 图书索引号 还书时间n); for(i=0;inext; fclose(fp2); struct node *loadone(void) int

9、 i; struct node *head1, *p,*q; struct book an; head1=(struct node *)malloc(sizeof(struct node); q=head1=NULL; if(fp1=fopen(a.txt,rb)=NULL)N YN while(!feof(fp1) Y return head1; for(i=0;izhanghao,ai.zhanghao); strcpy(p-num,ai.num); strcpy(p-suoyinhao,ai.suoyinhao); strcpy(p-time,ai.time); head1=p;p-ne

10、xt=q; q=head1;fclose(fp1); return head1; 3 程序实现3.1 程序实现时应考虑的问题 ; 3.2 主要源代码及说明 #include#include#define n 2 struct book /建立结构体数组 char zhanghao8; char num11; char suoyinhao6; char time10; char returntime10; an,bn,cn; struct node /建立结构体链表 char zhanghao8; char num11; char suoyinhao6; char time10; char re

11、turntime10; struct node *next; ; FILE *fp1,*fp2,*fp3; struct node *insertone(struct node *head1) /*输入a.txt中所有的信息,并构建新的带头结点的链表*/ int i; struct node *p,*q; head1=q=(struct node *)malloc(sizeof(struct node); printf( 欢迎进入借还书信息系统,请输入相关信息n); for(i=0;inext=p; q=p; p-next=0; return head1; struct node *inser

12、ttwo(struct node *head2) /*输入b.txt中所有的信息,并构建新的带头结点的链表*/ int i; struct node *p,*q; head2=q=(struct node *)malloc(sizeof(struct node); for(i=0;inext=p; q=p; p-next=0; return head2; void showone(struct node *head1) /*保存到a.txt文件中并显示出来*/ int i; struct node *temp; temp=head1; printf(a.txtn); fp1=fopen(a.t

13、xt,w); for(i=0;in;i+) if(fwrite(&ai,sizeof(struct book),1,fp1)!=1) /*将结构体数组ai中的数据写入a.txt文件*/ printf(文件写入数据错误n); fclose(fp1); fp1=fopen(a.txt,r); printf(n账号 学号 图书索引号 借书时间n); for(i=0;inext; fclose(fp1); void showtwo(struct node *head2) /*保存到b.txt文件中并显示出来*/ int i; struct node *temp; temp=head2; printf(

14、b.txtn); fp2=fopen(b.txt,w); for(i=0;in;i+) if(fwrite(&bi,sizeof(struct book),1,fp2)!=1) /*将结构体数组bi中的数据写入b.txt文件*/ printf(文件写入数据错误n); fclose(fp2); fp2=fopen(b.txt,r); printf(n账号 学号 图书索引号 还书时间n); for(i=0;inext; fclose(fp2); struct node *loadone(void) /*将文件a中的数据生成一个链表,如果文件不存在,则是一个空链*/ int i; struct no

15、de *head1, *p,*q; struct book an; head1=(struct node *)malloc(sizeof(struct node); q=head1=NULL; if(fp1=fopen(a.txt,rb)=NULL) return head1; else while(!feof(fp1) for(i=0;izhanghao,ai.zhanghao); strcpy(p-num,ai.num); strcpy(p-suoyinhao,ai.suoyinhao); strcpy(p-time,ai.time); head1=p; p-next=q; q=head1

16、; fclose(fp1); return head1; struct node *loadtwo(void) /*将文件b中的数据生成一个链表,如果文件不存在,则是一个空链*/ int i; struct node *head2, *p,*q; struct book bn; head2=(struct node *)malloc(sizeof(struct node); q=head2=NULL; if(fp2=fopen(b.txt,rb)=NULL) return head2; else while(!feof(fp2) for(i=0;izhanghao,bi.zhanghao);

17、strcpy(p-num,bi.num); strcpy(p-suoyinhao,bi.suoyinhao); strcpy(p-returntime,bi.returntime); head2=p; p-next=q; q=head2; fclose(fp2); return head2; void hebing(struct node *head1, struct node *head2) /*合并两个文件*/ char ch; FILE *fp1,*fp2,*fp3; if(fp1=fopen(a.txt,r)=NULL) printf(打开文件a.txt失败!n); exit(1);

18、else printf(打开文件a.txt成功!n); if(fp2=fopen(b.txt,r)=NULL) printf(打开文件b.txt失败!n); exit(2); else printf(打开文件b.txt成功!n); if(fp3=fopen(c.txt,r)=NULL) printf(打开文件c.txt失败!n); exit(3); else printf(打开文件c.txt成功!n);while(ch=fgetc(fp1)!=EOF) fputc(ch,fp3); while(ch=fgetc(fp2)!=EOF) fputc(ch,fp3); fclose(fp1); fc

19、lose(fp2); fclose(fp3); struct node *loadthree(void) /*将文件c中的数据生成一个链表,如果文件不存在,则是一个空链*/ int i; struct node *head, *p,*q; struct book cn; head=(struct node *)malloc(sizeof(struct node); q=head=NULL; if(fp3=fopen(c.txt,rb)=NULL) return head; else while(!feof(fp3) for(i=0;izhanghao); strcpy(ci.num,p-num

20、); strcpy(ci.suoyinhao,p-suoyinhao); strcpy(ci.time,p-time); strcpy(ci.returntime,p-returntime); head=p; p-next=q; q=head; fclose(fp3); return head; void showthree(struct node *head) /*保存c.txt文件中的信息并显示出来*/ int i; struct node *p; p=head; printf(c.txtn); fp3=fopen(c.txt,w); for(i=0;in;i+) if(fwrite(&ci,sizeof(struct book),1,fp3)!=1) printf(文件写入数据错误n); fclose(fp3); fp3=fopen(c.txt,r); printf(n账号 学号 图书索引号 借书时间 还书时间n); for(i=0;inext; fclose(fp3); main() struct node *head; struct node *head1; struct node *head2; head1=insertone(head1); /输入a.txt文件中的信息

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1