C客户积分管理系统v代码指导.docx
- 文档编号:1214988
- 上传时间:2023-04-30
- 格式:DOCX
- 页数:8
- 大小:13.32KB
C客户积分管理系统v代码指导.docx
《C客户积分管理系统v代码指导.docx》由会员分享,可在线阅读,更多相关《C客户积分管理系统v代码指导.docx(8页珍藏版)》请在冰点文库上搜索。
#include
#include
#include
#include"stdlib.h"
#include
usingnamespacestd;
boolisID(string&);
typedefstructcnode
{
charname[20];
stringID;
doubleconsume;
doubleinteger;
structcnode*next;
}cnode;
voidInitstack(cnode*&head)/*初始化链表*/
{
head=newcnode();//开辟节点空间
head->next=NULL;
}
void
voidGetelem(cnode*head);
voidSearch(cnode*head,string&ID);
voidAmend(cnode*head,string&ID);
voidDelete(cnode*head,string&ID);
voidShowall(cnode*head);
voidcount(cnode*head);
intmain()
{
cnode*head;
intchoice;
stringy;
Initstack(head);
do
{
cout< cout<<"客户消费积分管理系统"< cout<<"******************************"< cout<<"**"< cout<<"*主菜单*"< cout<<"*1添加客户*"< cout<<"*2查找客户*"< cout<<"*3修改客户*"< cout<<"*4删除客户*"< cout<<"*5显示客户*"< cout<<"*6统计客户*"< cout<<"*7退出*"< cout<<"**"< cout<<"******************************"< cout<<"请输入您的选择(1,2,3,4,5,6): "; cout<<"版权所有@广州六中林靖彬"; cin>>choice; if(choice==1) Getelem(head);//添加 elseif(choice==2) { cout<<"请输入您查找客户的电话号码: "; cin>>y; isID(y); Search(head,y);//查找 } elseif(choice==3) { cout<<"请输入您想修改客户的电话号码: "; cin>>y; isID(y); Amend(head,y); }//修改 elseif(choice==4) { cout<<"请输入你想要删除的客户的电话号码: "; cin>>y; isID(y); Delete(head,y); } //删除 elseif(choice==5) Showall(head);//显示 elseif(choice==6) count(head);//统计 elseif(choice==7) exit (1); } while(choice<=7); system("pause"); return0; } voidGetelem(cnode*head) { //添加客户函数以头节点为参数 cnode*p; doubley; p=newcnode; p->next=newcnode;/*申请空的节点空间*/ p->ID=""; cout<<"请输入姓名: "; cin>>p->name; cout<<"请输入电话号码: "; cin>>p->ID; isID(p->ID); cout<<"请输入消费金额: "; cin>>p->consume; p->integer=p->consume*100; cout<<"积分: "< p->next=head->next; head->next=p; } voidSearch(cnode*head,string&ID) { cnode*p=newcnode; doubley; p=head; if(p->next==NULL) cout<<"没有客户! "< else { while(p->next! =NULL) { p=p->next; if(ID==p->ID)//判断身份证号是否相同 { cout<<"姓名: "< cout<<"身份证号: "< cout<<"消费: "<*setprecision (2)<<*/p->consume< cout<<"积分: "< return; } } cout<<"不存在该客户! "< } } /* 修改客户函数 通过ID获取信息 可以修改身份证号、姓名、消费金额 修改消费金额有覆盖原有金额及续加两种方式 */ voidAmend(cnode*head,string&ID){ cnode*p; doubley,z; intchoose,x; p=head; if(p->next==NULL) cout<<"没有客户! "< else { while(p->next! =NULL) { p=p->next; if(ID==p->ID)//判断身份证号是否相同 { cout<<"姓名: "< cout<<"电话号码: "< cout<<"消费: "/*< (2)*/< cout<<"积分: "<*setprecision (1)<<*/p->integer< cout<<"请选择你要修改的1、姓名。 2、电话号码。 3、消费金额。 "; cin>>choose; if(choose==1) { cout<<"请输入修改后姓名;"; cin>>p->name; } if(choose==2) { cout<<"请输入修改后的电话号码: "; cin>>p->ID; isID(p->ID); } if(choose==3) { cout<<"1.覆盖以前消费、2.续加上现在费用! 请选择: "; cin>>x; if(x==1) { cout<<"请输入修改后的消费: "; cin>>p->consume; } else{ printf("请输入续加金额: "); cin>>z; p->consume+=z; } } cout<<"姓名: "< cout<<"电话号码: "< cout<<"消费: "<*setprecision (2)<<*/p->consume< p->integer=p->consume/100.0; cout<<"积分: "< return; } } cout<<"不存在该客户! "< } } voidDelete(cnode*head,string&ID) { //删除客户函数 cnode*p; intx; doubley; p=head; if(p->next==NULL) cout<<"没有客户! "< else { while(p->next! =NULL) { head=p; p=p->next; if(ID==p->ID) {//判断身份证号是否相同 cout<<"姓名: "< cout<<"电话号码: "< cout<<"消费: "/*< (2)*/< cout<<"积分: "< cin>>x; if(x==1) { head->next=p->next; cout<<("删除成功! "); } else cout<<"删除失败! "; return; } } cout<<"不存在该客户! "< } } voidShowall(cnode*head)//显示所有客户函数 { cnode*p; doubley; p=head; if(p->next==NULL) cout<<"没有客户! "< else while(p->next! =NULL) { p=p->next; cout<<"姓名: "< cout<<"电话号码: "< cout<<"消费: "<*setprecision (2)<<*/p->consume< cout<<"积分: "< } } voidcount(cnode*head) { cnode*p; inti=0; p=head; if(p->next==NULL) cout<<"没有客户! "< else while(p->next! =NULL) { p=p->next; i++; } cout<<"现有客户数量为"< "< } intcal(stringa) { return(a[0]-'0')*7+(a[1]-'0')*9+(a[2]-'0')*10+(a[3]-'0')*5+(a[4]-'0')*8+ (a[5]-'0')*4+(a[6]-'0')*2+(a[7]-'0')*1+(a[8]-'0')*6+(a[9]-'0')*3+ (a[10]-'0')*7+(a[11]-'0')*9+(a[12]-'0')*10+(a[13]-'0')*5+(a[14]-'0')*8+ (a[15]-'0')*4+(a[16]-'0')*2; } chars(stringa) { intk=cal(a)%11; if(k==0) return'1'; elseif(k==1) return'0'; elseif(k==2) return'X'; else return'0'+12-k; } boolisNumber(stringstr); boolisID(string&number) { do { if(11==number.length()&&isNumber(number)) if(number[10]==s(number)) returntrue; else returnfalse; else cout<<"输入格式不正确,请重新输入: "< }while(cin>>number); } boolisNumber(stringstr) { for(inti=0;i if(! isdigit(str[i])) returnfalse; if((isdigit(str[str.length()-1]))||str[str.length()-1]=='X') returntrue; else returnfalse; }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 客户 积分 管理 系统 代码 指导