#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int Winlogon();
int Manage();
void drawmoney();
void deposit();
void transfer();
void balance();
void open();
void closing();
void modify();
void information();
struct CCard
{
char card[20];
char password[7];
int flag;
float account;
};
struct CCard C1[5];
int Winlogon()
{
int i=0;
int n;
char input[10]={0};
printf("\n请输入您的卡号:");
scanf("%c",&C1[0].card);
getchar();
gets(input);
if(strcmp(C1[0].card,C1[0].card)==0)
{
printf("\n请输入您的密码:");
scanf("%C",&C1[0].password);
getchar();
while(++i <= 3)
{
gets(input);
if(strcmp(C1[0].password,C1[0].password)==0)
{
{
printf("\n登陆成功,请输入相应编号进行以下操作:");
printf("\n------------------------------------------------1.存款---------------------------------------------------------------");
printf("\n------------------------------------------------2.取款---------------------------------------------------------------");
printf("\n------------------------------------------------3.转账---------------------------------------------------------------");
printf("\n------------------------------------------------4.余额查询-----------------------------------------------------------");
printf("\n------------------------------------------------5.退出程序-----------------------------------------------------------");
scanf("%d",&n);
}
switch(n)
{
case 1:drawmoney();break;
case 2:deposit();break;
case 3:transfer();break;
case 4:balance();break;
case 5:exit(0);
default:printf("\n输入错误,请重新输入!");break;
}
}
else
{
printf("\n密码错误,请重新输入!");
break;
}
if(i<3)
{
printf("\n请重新输入密码,你还有%d次机会",3-i);
}
else
{
printf("\n密码错误已超过三次,你的账户已被冻结!");
}
}
}
else
{
printf("\n您输入的卡号有误,请重新输入:");
}
return 1;
}
int Manage()
{
int n;
char m[10]="123";
char input[10]={0};
printf("\n请输入管理员密码:");
scanf("%c",&m[10]);
gets(input);
if(strcmp(m,input)==0)
{
{
printf("\n------------------------------------------------1.添加银行卡---------------------------------------------------------------");
printf("\n------------------------------------------------2.删除银行卡---------------------------------------------------------------");
printf("\n------------------------------------------------3.改密---------------------------------------------------------------------");
printf("\n------------------------------------------------4.信息查询-----------------------------------------------------------------");
printf("\n------------------------------------------------5.退出程序---------------------------------------------------------\n");
printf("\n登陆成功,请输入相应编号进行以下操作:");
scanf("%d",&n);
}
switch(n)
{
case 1:open();break;
case 2:closing();break;
case 3:modify();break;
case 4:information();break;
case 5:exit(0);
default:printf("\n输入错误,请重新输入!");
}
}
else
{
printf("\n密码错误,请重新输入");
}
return 1;
}
void drawmoney()
{
struct CCard C1={"000000000","000000",1,000};
int Num;
printf("\n请输入存款金额:");
scanf("%d",&Num);
C1.account=C1.account+Num;
getchar();
printf("\n请把你的钱放到指定位置----");
}
void deposit()
{
struct CCard C1={"000000000","000000",1,000};;
char x;
printf("\n请输入取款金额:");
scanf("%f",&x);
if(C1.account>=x)
{
C1.account=C1.account-x;
printf("\n请取走您的钱----");
}
else
printf("\n对不起,您的余额不足----");
}
void transfer()
{
struct CCard C1[5];
char y;
printf("\n请输入需要转账的银行卡号:");
scanf("%c",&C1[5].card);
printf("\n请输入转账金额:");
scanf("%f",&y);
if(C1[5].account>y)
{
C1[0].account=C1[0].account-y;
C1[1].account=C1[1].account+y;
printf("\n恭喜您转账成功----");
}
else
{
printf("\n对不起,您的余额不足----");
}
}
void balance()
{
printf("\n您的银行卡余额剩余10000元----");
}
void open()
{
printf("\n请依次输入卡号,密码,余额");
scanf("%c%d%f",C1[5].card,C1[5].password,&C1[5].account);
printf("\n添加银行卡成功!!!");
}
void closing()
{
printf("\n请依次输入卡号,密码,余额");
scanf("%c%d%f",C1[5].card,C1[5].password,&C1[5].account);
printf("\n删除银行卡成功!!!");
}
void modify()
{
struct CCard C1[5];
char newpassword;
printf("\n请输入您需要改密的银行卡卡号:");
scanf("%c",&C1[5].card);
printf("\n请输入您的旧密码:");
scanf("%c",&C1[5].password);
if(strcmp("card C1[5]","password C1[5]")==0)
{
printf("\n请输入您的新密码:");
scanf("%c",&newpassword);
printf("\n请再次输入");
scanf("%c",&newpassword);
printf("\n密码修改成功,请牢记!!!");
}
else
printf("\n密码错误,请重新输入!!");
}
void information()
{
printf("\n系统故障,请稍后再来!!!");
}
int main()
{
int n;
printf("\n\n-----------------------------------------------欢迎进入银行管理系统!---------------------------------------------------");
printf("\n\n-----------------------------------------------管理员密码:123----------------------------------------------------------");
printf("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
printf("\n-----------------------------------------------1.银行卡管理--------------------------------------------------------------");
printf("\n-----------------------------------------------2.银行卡登录--------------------------------------------------------------");
printf("\n请输入相应编号进行以下操作:");
scanf("%d",&n);
switch(n)
{
case 1:Manage();break;
case 2:Winlogon();break;
case 3:exit(0);
default:printf("\n输入错误,请重新输入!");
}
return 0;
}