C语言购物卡管理系统链表

上传人:cl****1 文档编号:457764028 上传时间:2023-07-14 格式:DOC 页数:28 大小:51KB
返回 下载 相关 举报
C语言购物卡管理系统链表_第1页
第1页 / 共28页
C语言购物卡管理系统链表_第2页
第2页 / 共28页
C语言购物卡管理系统链表_第3页
第3页 / 共28页
C语言购物卡管理系统链表_第4页
第4页 / 共28页
C语言购物卡管理系统链表_第5页
第5页 / 共28页
点击查看更多>>
资源描述

《C语言购物卡管理系统链表》由会员分享,可在线阅读,更多相关《C语言购物卡管理系统链表(28页珍藏版)》请在金锄头文库上搜索。

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

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

3、en;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(文件写入错误!);fclose(fp

4、);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 *duqu()/读取数据 st

5、ruct 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(hea

6、d=NULL) head=p2=p1; else p2-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(%s,head-

7、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);printf(ntt*注册购物

8、卡*nnn);printf(您的购物卡为:nn);printf(nt姓 名 卡 号 余 额 积分 nn);printf(t%2s %16s %13.2f %13.2f,p-name,p-number,p-money,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-number,p-number)!=0)

9、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 *p,*a;p=duqu();a=p;whi

10、le(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)char 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对不起,两次输入的密码不一样,修改密码失败!

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号