📄 信用卡.cpp
字号:
#include<iostream.h>
struct kar
{
int id;
int password;
double nummoney;
kar*next;
};
kar * head=NULL;
kar* pm=NULL;
kar* pe=NULL;
kar* f=NULL;
int id,password;
void found(int id);
kar* createid()
{
pe=new kar;
while(pe==NULL)
{
pe=new kar;
}
cout<<"请设置你的号码和密码:"<<endl;
cin>>id>>password;
pe->id=id;
pe->password=password;
pe->nummoney=0;
if(head==NULL)
{
head=pe;
f=head;
pm=pe;
}
else
{
pm->next=pe;
pm=pe;
}
pe->next=NULL;
found(id);
return head;
}
void found(int id)
{
f=head;
while(f!=NULL&&f->id!=id)
f=f->next;
if(f!=NULL)
;
else
cout<<"此卡号不存在"<<endl;
}
bool checkpassword(int id,int password)
{
found(id);
if(f->password==password)
return 1;
else
return 0;
}
double getmoney()
{
return f->nummoney;
}
double savemoney(int num)
{
f->nummoney=f->nummoney+num;
return f->nummoney;
}
double takemoney(int num)
{
f->nummoney=f->nummoney-num;
if(f->nummoney>=0)
cout<<"你现有余额为:"<<f->nummoney<<endl;
else
cout<<"你的余额不足"<<endl;
return f->nummoney;
}
void setpassword(int newpassword)
{
f->password=newpassword;
}
void changemoney(int idg,int num)
{
f->nummoney=f->nummoney-num;
if(f->nummoney>=0)
cout<<" 你现有余额不够"<<endl;
found(idg);
if(f!=NULL)
f->nummoney=f->nummoney+num;
else
cout<<"收款帐号不存在"<<endl;
}
void main()
{
int n=0,num=0;
bool ft=false;
createid();
cout<<"请输入帐号和密码"<<endl;
cin>>id>>password;
// ft=checkpassword(id,password);
do
{
ft=checkpassword(id,password);
if(ft)
{
cout<<"申请账号---1;修改密码----2;查询账号---3;"
<<endl<<"取款——4; 存款----5;转帐--6;定位---7;退出--8"<<endl;
cin>>n;
switch(n)
{
case 1:createid();break;
case 2:cout<<"请输入新密码";
cin>>password;
setpassword(password);break;
case 3: cout<<"你现有余额为:"<<getmoney()<<endl;break;
case 4:cout<<"请输入数目";
cin>>num;
takemoney(num);break;
case 5:cout<<"请输入数目";
cin>>num;
savemoney(num);break;
case 6:
cout<<"请输入对方的帐号t和数目"<<endl;
cin>>id>>num;
changemoney(id,num);break;
case 7:cout<<" 请输入帐号和密码:"<<endl;
cin>>id>>password;
found(id);
break;
case 8:break;
default:cout<<"你输入不符要求的数字"<<endl;
}
}
else
{
cout<<" 你的帐号和密码不对,请重试"<<endl;
cin>>id>>password;
}
}while(n!=8);
cout<<"伍东方"<<endl;
delete pe;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -