C语言购物卡管理系统(链表)_第1页
C语言购物卡管理系统(链表)_第2页
C语言购物卡管理系统(链表)_第3页
C语言购物卡管理系统(链表)_第4页
C语言购物卡管理系统(链表)_第5页
已阅读5页,还剩28页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、共享知识分享快乐购物卡管理系统(一)系统主要功能模块:(1)实现系统内制卡、发卡功能。(2)实现系统内购物卡帐户及相关帐户管理。(3)实现购物卡交易和合法性检查。(4)实现购物卡交易积分功能。(5)实现购物卡报表功能。(6)数据以文件形式存储。提示:制卡:指申请一个购物卡,但还没有使用。发卡:指该卡已经起用。实现卡交易:指从卡中消费掉一定金额。(二)题目及要求的分析:根据题目要求,系统应该实现以下功能:(1)制卡:主要是新建出一张购物卡,并输入了顾客部分信息,如姓名、密码等,但卡没有激活,依然不可使用。(2)发卡:激活新建的购物卡,用户能够使用卡进行各项活动。(3)消费:进入帐户后,取走少于帐

2、户金额的钱款进行消费,并在帐户少减少相应的金额,增加相应的积分。(4)存款:进入帐户后,在金额项加上用户要存入的钱款。(5)报表:显示顾客购物卡上记录的所有信息,除密码外。(6)存储:购物卡内的信息以文件形式存储。(7)退出:从系统中退出。(8)菜单:提供良好的界面,方便用户的操作。代码:#include vstdi o.h#include/*调用字符函数*/#include #include/*通用输入输出库*/#include#includeint flag=5;struct cardchar name20;char number20;float money;char key10;floa

3、t jifen;float mid;int power;struct card *next;save(struct card *head);void list();void jihuo();struct card *chaxun();save(struct card *head)FILE *fp;struct card *q;q=head;if(fp=fopen(e:123.txt,ab+)=NULL)printf( 无法打开 n);exit(0); while(q!=NULL)if(fwrite(q,sizeof(struct card),1,fp)!=1)printf( 文件写入错误 !)

4、;fclose(fp);return (head);q=q-next;fclose(fp);struct card *save1(struct card *head)FILE *fp;struct card *q;q=head;if(fp=fopen(e:123.txt,wb)=NULL)printf( 无法打开 n);exit(0); while(q!=NULL)if(fwrite(q,sizeof(struct card),1,fp)!=1)printf( 文件写入错误 !);fclose(fp);return (head);q=q-next; fclose(fp);struct card

5、 *duqu()/ 读取数据struct card *head = NULL;struct card *p1, *p2;FILE *fp;if(fp=fopen(e:123.txt,rb+)=NULL)printf( 打开文件出错 n);exit(0);while(!feof(fp)if(p1=(struct card*)malloc(sizeof(struct card)=NULL)printf(something is wrong!n);fclose(fp);exit(0);if(fread(p1,sizeof(struct card),1,fp)!=1)free(p1);break;if

6、(head=NULL)head=p2=p1;elsep2-next=p1;p2=p1;fclose(fp);return (head);struct card *createlist()struct card *head,*p,*q;int i;char num20;head=(struct card*)malloc(sizeof(struct card);head-next=NULL;head-money=0;head-jifen=0;system(cls);printf(ntt*注册购物卡*nnn);越努力越幸运doprintf(nnt 请输入要注册的卡号(六位数) : );scanf(%

7、s,head-number);if(strlen(head-number)!=6)system(cls);printf(nnnnnnnnnnttt 对不起您的输入有误,请重新输入 !nn);Sleep(1000);system(cls);printf(ntt*注册购物卡*nnn);continue;printf(nnt 请输入您的名字 : );scanf(%s,head-name);printf(nnt 请输入您的密码 : );scanf(%s,head-key);head-power=99;while(strlen(head-number)!=6);p=head;system(cls);pr

8、intf(ntt*注册购物卡*nnn);printf( 您的购物卡为: nn);printf(nt 姓 名 卡 号 余 额积分 nn);printf(t%2s %16s %13.2f %13.2f,p-name,p-number,p-mo ney,p-jifen);getche();p-next=NULL;save(head);printf(nnnnnnttt);printf( 购物卡注册成功 !nnnntttt 按任意键返回 );getche();void cost(struct card *q)struct card *p,*a;p=duqu();a=p;while(strcmp(q-nu

9、mber,p-number)!=0)p=p-next;system(cls);printf(ntt*账户消费*nnn);printf(nnnnnn);printf(ttt 请输入您的消费金额: );scanf(%f,&p-mid);(p-money)=(p-money)-(p-mid);(p-jifen)=(p-jifen)+(p-mid);printf(nnttt 您的余额为: %.2f,p-money);printf(nnnnnttt 显示完毕,按任意键返回子菜单 );getche();p=a;save1(p);void cunkuan(struct card *q)struct card

10、 *p,*a;p=duqu();a=p;while(strcmp(q-number,p-number)!=0)p=p-next;system(cls);printf(ntt*账户存款*nnn);printf(nnnnnn);printf(ttt 请输入您的存款金额: );scanf(%f,&p-mid);(p-money)=(p-mid)+(p-money);printf(nnttt 您的余额为: %.2f,p-money);printf(nnnnnttt 显示完毕,按任意键返回子菜单 );getche();p=a;save1(p);void xiugai(struct card *q)cha

11、r key10,num10;struct card *p,*a;p=duqu();a=p;while(strcmp(q-number,p-number)!=0)p=p-next;system(cls);printf(ntt*修改账户密码*nnn);printf(nnnn);printf(ttt 请输入您的新密码: );scanf(%s,num);printf(nnttt 请再次输入您的密码: );scanf(%s,key);if(strcmp(key,num)!=0)system(cls);printf(ntt*修改账户密码*nnn);printf(nnnnntt 对不起,两次输入的密码不一样

12、, 修改密 码失败 !);Sleep(1000);system(cls);if(strcmp(key,num)=0)system(cls);printf(ntt*修改账户密码*nnn);strcpy(p-key,num);printf(nnnnnnttt 修改密码成功 !);Sleep(1000);p=a;save1(p);void chaxun2(struct card *q) struct card *p,*a;p=duqu();a=p;while(strcmp(q-number,p-number)!=0)p=p-next;system(cls);printf(ntt*账户查询*nnn);

13、printf(t 您的账户信息为: nnn);printf(ntt 姓 名 卡 号额 积分 nn);printf(tt%2s %16s %13.2f %13.2f,p-name,p-number,p-money,p-jifen);printf(n);getch();struct card *chaxun()int b,i=0;int flag=9;struct card *head;char num10,key10;struct card *p,*head1;head1=duqu();p=head1;system(cls);printf(ntt*账户登陆*nnn);printf(nnt 请输入

14、您的卡号(六位数) : );scanf(%s,num);while(p!=NULL)if(strcmp(num,p-number)!=0)p=p-next;if(p=NULL)账户登陆system(cls);printf(ntt* * *nnn);printf(nnnnnnnttt 没有该卡号信息 ,请重新输入!nn);Sleep(1000);账户登陆system(cls);printf(ntt* * *nnn);printf(nnt 请重新输入卡号 (六位数 ): );scanf(%s,num);p=head1;continue;if(p-power)=99)system(cls);prin

15、tf(ntt*账户登陆*nnn);printf(nnnnnnnttt 对不起,该卡未激活,请先激活!);getche();system(cls);main();if(p-power=100)while(flag=9)printf(nnt 请输入密码(六位数) : );scanf(%s,key);if(strcmp(key,p-key)=0)flag=10;if(strcmp(key,p-key)!=0)system(cls);printf(ntt*账户登陆*nnn);printf(nnnnnnnttt 对不起 ,密码输入错误 %d次!,i+1);flag=9;i+;if(i=3)system(

16、cls); printf(nnnnnnnttt 密码输入错误三次, 系统 自动返回主菜单! );Sleep(2000);system(cls);return;if(flag=10)break;while(1)system(cls);账户查询printf(*printf(*n);printf(*n);printf(*n);printf(*n);1:查询2:存款printf(*n);printf(*n);printf(*n);printf(*n);printf(3:消费*n);printf(*n);printf(*n);printf( *4:修改密码*n);printf( *n);printf(

17、*5:返回主菜单*n);printf( *n);printf(*n);printf(n);printf(tt 请选择操作 : );scanf(%d,&b);switch(b)case 1:chaxun2(p); break;case 2:cunkuan(p);break;case 3:cost(p);break;case 4:xiugai(p);break;case 5:main();default:printf( 对不起,您的输入有误,请重新输入! );void jihuo()char x;char num10;struct card *p,*head1;head1=duqu();p=hea

18、d1;system(cls);printf(ntt*激活购物卡*nnn);printf(t 请输入您要激活的卡号(六位数) : );scanf(%s,num);while(p!=NULL)if(strcmp(num,p-number)!=0)p=p-next;elsebreak;while(p=NULL)激活购物卡system(cls);printf(ntt*nnn);printf(nnnnnnttt 没有该卡号信息 ,请重新输入卡号!nn);Sleep(1000);激活购物卡system(cls);printf(ntt*nnn);printf(t 请重新输入您申请的卡号 (六位数): );s

19、canf(%s,num);p=head1;rKnQvauoul4daqumu4d(luleu4dcz2L%s2L% 49L% sz%?)tulF.55O 更愿申平 如載=u厂)tulT.UM 吴平畀S星嵋)tul=5u 一 ur*is$u 厂)t.EdF.So.JUlgsASWSMO 玉呈#esOOE蚩 odc.d=5u 一 ur*is$u 厂)t.EdJh aseo(xrEPWS=xodo% )4U 易r-牴娯艺W5U 厂)tul共享知识 分享快乐printf( 激活成功 ,按任意键返回主菜单 );getche();break;case 2:system(cls);printf(ntt*激活

20、购物卡*nnn);越努力越幸运printf(nnnnnnnttt);printf( 您已放弃激活,按任意键返回主菜单 );getche();break;default:system(cls);printf(ntt*激活购物卡*nnn);printf(nnnnnnnttt);printf( 对不起,您的输入有误,请重新输入! );Sleep(2000);void list()struct card *p1;p1=duqu();system(cls);printf(ntt*显示购物卡*nnn);printf( 所有购物卡信息为: nnn);printf(nt 姓 名 卡 号 余 额积分 nn);while(p1!=NULL)printf(t %2s %16s %14.2f %14.2f,p1-name,p1-number,p1-money,p1-jifen);printf(n);p1=p1-next;main()int a;struct *head;printf(nnnnnnnntttt); printf( 欢迎使用 ); p

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论