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

上传人:b****6 文档编号:13431900 上传时间:2023-06-14 格式:DOCX 页数:22 大小:18.28KB
下载 相关 举报
C语言购物卡管理系统链表.docx_第1页
第1页 / 共22页
C语言购物卡管理系统链表.docx_第2页
第2页 / 共22页
C语言购物卡管理系统链表.docx_第3页
第3页 / 共22页
C语言购物卡管理系统链表.docx_第4页
第4页 / 共22页
C语言购物卡管理系统链表.docx_第5页
第5页 / 共22页
C语言购物卡管理系统链表.docx_第6页
第6页 / 共22页
C语言购物卡管理系统链表.docx_第7页
第7页 / 共22页
C语言购物卡管理系统链表.docx_第8页
第8页 / 共22页
C语言购物卡管理系统链表.docx_第9页
第9页 / 共22页
C语言购物卡管理系统链表.docx_第10页
第10页 / 共22页
C语言购物卡管理系统链表.docx_第11页
第11页 / 共22页
C语言购物卡管理系统链表.docx_第12页
第12页 / 共22页
C语言购物卡管理系统链表.docx_第13页
第13页 / 共22页
C语言购物卡管理系统链表.docx_第14页
第14页 / 共22页
C语言购物卡管理系统链表.docx_第15页
第15页 / 共22页
C语言购物卡管理系统链表.docx_第16页
第16页 / 共22页
C语言购物卡管理系统链表.docx_第17页
第17页 / 共22页
C语言购物卡管理系统链表.docx_第18页
第18页 / 共22页
C语言购物卡管理系统链表.docx_第19页
第19页 / 共22页
C语言购物卡管理系统链表.docx_第20页
第20页 / 共22页
亲,该文档总共22页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

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

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

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

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

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

购物卡管理系统

(一)系统主要功能模块:

 

(1)实现系统内制卡、发卡功能。

 

(2)实现系统内购物卡帐户及相关帐户管理。

 (3)实现购物卡交易和合法性检查。

 (4)实现购物卡交易积分功能。

 (5)实现购物卡报表功能。

(6)数据以文件形式存储。

 提示:

 

制卡:

指申请一个购物卡,但还没有使用。

 

发卡:

指该卡已经起用。

 

实现卡交易:

指从卡中消费掉一定金额。

 

(二)题目及要求的分析:

根据题目要求,系统应该实现以下功能:

(1)制卡:

主要是新建出一张购物卡,并输入了顾客部分信息,如姓名、密码等,但卡没有激活,依然不可使用。

 

(2)发卡:

激活新建的购物卡,用户能够使用卡进行各项活动。

 (3)消费:

进入帐户后,取走少于帐户金额的钱款进行消费,并在帐户少减

少相应的金额,增加相应的积分。

 (4)存款:

进入帐户后,在金额项加上用户要存入的钱款。

 (5)报表:

显示顾客购物卡上记录的所有信息,除密码外。

 (6)存储:

购物卡内的信息以文件形式存储。

 (7)退出:

从系统中退出。

 (8)菜单:

提供良好的界面,方便用户的操作。

代码:

#include

#include/*调用字符函数*/

#include

#include/*通用输入输出库*/

#include

#include

intflag=5;

structcard

{

charname[20];

charnumber[20];

floatmoney;

charkey[10];

floatjifen;

floatmid;

intpower;

structcard*next;

};

save(structcard*head);

voidlist();

voidjihuo();

structcard*chaxun();

 

save(structcard*head)

{

FILE*fp;

structcard*q;

q=head;

if((fp=fopen("e:

\\123.txt","ab+"))==NULL)

{

printf("无法打开\n");

exit(0);

}

while(q!

=NULL)

{

if(fwrite(q,sizeof(structcard),1,fp)!

=1)

{

printf("文件写入错误!

");

fclose(fp);

return(head);

}

q=q->next;

}

fclose(fp);

}

 

structcard*save1(structcard*head)

{

FILE*fp;

structcard*q;

q=head;

if((fp=fopen("e:

\\123.txt","wb"))==NULL)

{

printf("无法打开\n");

exit(0);

}

while(q!

=NULL)

{

if(fwrite(q,sizeof(structcard),1,fp)!

=1)

{

printf("文件写入错误!

");

fclose(fp);

return(head);

}

q=q->next;

}

fclose(fp);

}

structcard*duqu()//读取数据

{

structcard*head=NULL;

structcard*p1,*p2;

FILE*fp;

if((fp=fopen("e:

\\123.txt","rb+"))==NULL)

{

printf("打开文件出错\n");

exit(0);

}

while(!

feof(fp))

{

if((p1=(structcard*)malloc(sizeof(structcard)))==NULL)

{

printf("somethingiswrong!

\n");

fclose(fp);

exit(0);

}

if(fread(p1,sizeof(structcard),1,fp)!

=1)

{

free(p1);

break;

}

if(head==NULL)

head=p2=p1;

else

{

p2->next=p1;

p2=p1;

}

}

fclose(fp);

return(head);

}

structcard*createlist()

{

structcard*head,*p,*q;

inti;

charnum[20];

head=(structcard*)malloc(sizeof(structcard));

head->next=NULL;

head->money=0;

head->jifen=0;

system("cls");

printf("\n\t\t********************注册购物卡*******************\n\n\n");

do

{

printf("\n\n\t请输入要注册的卡号(六位数):

");

scanf("%s",head->number);

if(strlen(head->number)!

=6)

{

system("cls");

printf("\n\n\n\n\n\n\n\n\n\n\t\t\t对不起您的输入有误,请重新输入!

\n\n");

Sleep(1000);

system("cls");

printf("\n\t\t********************注册购物卡*******************\n\n\n");

continue;

}

printf("\n\n\t请输入您的名字:

");

scanf("%s",head->name);

printf("\n\n\t请输入您的密码:

");

scanf("%s",head->key);

head->power=99;

}

while(strlen(head->number)!

=6);

p=head;

system("cls");

printf("\n\t\t********************注册购物卡*******************\n\n\n");

printf("您的购物卡为:

\n\n");

printf("\n\t姓名卡号余额积分\n\n");

printf("\t%2s%16s%13.2f%13.2f",p->name,p->number,p->money,p->jifen);

getche();

p->next=NULL;

save(head);

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

printf("购物卡注册成功!

\n\n\n\n\t\t\t\t按任意键返回.....");

getche();

}

voidcost(structcard*q)

{

structcard*p,*a;

p=duqu();

a=p;

while(strcmp(q->number,p->number)!

=0)

{

p=p->next;

}

system("cls");

printf("\n\t\t********************账户消费*******************\n\n\n");

printf("\n\n\n\n\n\n");

printf("\t\t\t请输入您的消费金额:

");

scanf("%f",&p->mid);

(p->money)=(p->money)-(p->mid);

(p->jifen)=(p->jifen)+(p->mid);

printf("\n\n\t\t\t您的余额为:

%.2f",p->money);

printf("\n\n\n\n\n\t\t\t显示完毕,按任意键返回子菜单.....");

getche();

p=a;

save1(p);

}

voidcunkuan(structcard*q)

{

structcard*p,*a;

p=duqu();

a=p;

while(strcmp(q->number,p->number)!

=0)

{

p=p->next;

}

system("cls");

printf("\n\t\t********************账户存款*******************\n\n\n");

printf("\n\n\n\n\n\n");

printf("\t\t\t请输入您的存款金额:

");

scanf("%f",&p->mid);

(p->money)=(p->mid)+(p->money);

printf("\n\n\t\t\t您的余额为:

%.2f",p->money);

printf("\n\n\n\n\n\t\t\t显示完毕,按任意键返回子菜单.....");

getche();

p=a;

save1(p);

}

voidxiugai(structcard*q)

{

charkey[10],num[10];

structcard*p,*a;

p=duqu();

a=p;

while(strcmp(q->number,p->number)!

=0)

{

p=p->next;

}

system("cls");

printf("\n\t\t********************修改账户密码*******************\n\n\n");

printf("\n\n\n\n");

printf("\t\t\t请输入您的新密码:

");

scanf("%s",num);

printf("\n\n\t\t\t请再次输入您的密码:

");

scanf("%s",key);

if(strcmp(key,num)!

=0)

{

system("cls");

printf("\n\t\t********************修改账户密码*******************\n\n\n");

printf("\n\n\n\n\n\t\t对不起,两次输入的密码不一样,修改密码失败!

");

Sleep(1000);

system("cls");

}

if(strcmp(key,num)==0)

{

system("cls");

printf("\n\t\t********************修改账户密码*******************\n\n\n");

strcpy(p->key,num);

printf("\n\n\n\n\n\n\t\t\t修改密码成功!

");

Sleep(1000);

p=a;

save1(p);

}

}

voidchaxun2(structcard*q)

{

structcard*p,*a;

p=duqu();

a=p;

while(strcmp(q->number,p->number)!

=0)

{

p=p->next;

}

system("cls");

printf("\n\t\t********************账户查询*******************\n\n\n");

printf("\t您的账户信息为:

\n\n\n");

printf("\n\t\t姓名卡号余额积分\n\n");

printf("\t\t%2s%16s%13.2f%13.2f",p->name,p->number,p->money,p->jifen);

printf("\n");

getch();

}

structcard*chaxun()

{

intb,i=0;

intflag=9;

structcard*head;

charnum[10],key[10];

structcard*p,*head1;

head1=duqu();

p=head1;

system("cls");

printf("\n\t\t********************账户登陆*******************\n\n\n");

printf("\n\n\t请输入您的卡号(六位数):

");

scanf("%s",num);

while(p!

=NULL)

{

if(strcmp(num,p->number)!

=0)

{

p=p->next;

if(p==NULL)

{

system("cls");

printf("\n\t\t********************账户登陆*******************\n\n\n");

printf("\n\n\n\n\n\n\n\t\t\t没有该卡号信息,请重新输入!

\n\n");

Sleep(1000);

system("cls");

printf("\n\t\t********************账户登陆*******************\n\n\n");

printf("\n\n\t请重新输入卡号(六位数):

");

scanf("%s",num);

p=head1;

}

continue;

}

if((p->power)==99)

{

system("cls");

printf("\n\t\t********************账户登陆*******************\n\n\n");

printf("\n\n\n\n\n\n\n\t\t\t对不起,该卡未激活,请先激活!

");

getche();

system("cls");

main();

}

if(p->power==100)

{

while(flag==9)

{

printf("\n\n\t请输入密码(六位数):

");

scanf("%s",key);

if(strcmp(key,p->key)==0)

{

flag=10;

}

if(strcmp(key,p->key)!

=0)

{

system("cls");

printf("\n\t\t********************账户登陆*******************\n\n\n");

printf("\n\n\n\n\n\n\n\t\t\t对不起,密码输入错误%d次!

",i+1);

flag=9;

i++;

if(i==3)

{

system("cls");

printf("\n\n\n\n\n\n\n\t\t\t密码输入错误三次,系统自动返回主菜单!

");

Sleep(2000);

system("cls");

return;

}

}

}

if(flag==10)

break;

}

}

while

(1)

{

system("cls");

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

printf("**\n");

printf("*账户查询*\n");

printf("**\n");

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

printf("**\n");

printf("*1:

查询*\n");

printf("**\n");

printf("*2:

存款*\n");

printf("**\n");

printf("*3:

消费*\n");

printf("**\n");

printf("*4:

修改密码*\n");

printf("**\n");

printf("*5:

返回主菜单*\n");

printf("**\n");

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

printf("\n");

printf("\t\t请选择操作:

");

scanf("%d",&b);

switch(b)

{

case1:

chaxun2(p);break;

case2:

cunkuan(p);break;

case3:

cost(p);break;

case4:

xiugai(p);break;

case5:

main();

default:

printf("对不起,您的输入有误,请重新输入!

");

}

}

}

voidjihuo()

{

charx;

charnum[10];

structcard*p,*head1;

head1=duqu();

p=head1;

system("cls");

printf("\n\t\t********************激活购物卡*******************\n\n\n");

printf("\t请输入您要激活的卡号(六位数):

");

scanf("%s",num);

while(p!

=NULL)

{

if(strcmp(num,p->number)!

=0)

{

p=p->next;

}

else

break;

while(p==NULL)

{

system("cls");

printf("\n\t\t********************激活购物卡*******************\n\n\n");

printf("\n\n\n\n\n\n\t\t\t没有该卡号信息,请重新输入卡号!

\n\n");

Sleep(1000);

system("cls");

printf("\n\t\t********************激活购物卡*******************\n\n\n");

printf("\t请重新输入您申请的卡号(六位数):

");

scanf("%s",num);

p=head1;

}

}

system("cls");

printf("\n\t\t********************激活购物卡*******************\n\n\n");

printf("您的购物卡为:

\n\n");

printf("\n\t姓名卡号余额积分\n\n");

printf("\t%2s%16s%13.2f%13.2f",p->name,p->number,p->money,p->jifen);

printf("\n\n\n\n\n\t\t\t确认激活您的购物卡?

\n\n\t\t\t<1>是<2>否");

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

");

scanf("%c",&x);

switch(x)

{

case'1':

system("cls");

printf("\n\t\t********************激活购物卡*******************\n\n\n");

p->power=100;

save1(head1);

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

printf("激活成功,按任意键返回主菜单.....");

getche();

break;

case'2':

system("cls");

printf("\n\t\t********************激活购物卡*******************\n\n\n");

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

printf("您已放弃激活,按任意键返回主菜单.....");

getche();

break;

default:

system("cls");

printf("\n\t\t********************激活购物卡*******************\n\n\n");

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

printf("对不起,您的输入有误,请重新输入!

");

Sleep(2000);

}

}

voidlist()

{

structcard*p1;

p1=duqu();

system("cls");

printf("\n\t\t********************显示购物卡*******************\n\n\n");

printf("所有购物卡信息为:

\n\n\n");

printf("\n\t姓名卡号余额积分\n\n");

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()

{

inta;

struct*head;

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

printf("欢迎使用");

printf("\n\n");

printf("\t******************购物卡管理系统****

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

当前位置:首页 > 医药卫生 > 基础医学

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

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