首页 > 代码库 > C语言后ATM第一次尝试

C语言后ATM第一次尝试

#include <stdio.h>
#define PASSWORD 9527
#define RMB 100000
#define DORROR 10000
void exit(int x)
{
while(x != 0)
{
printf("0:Cancle\n");
scanf("%d",&x);
}
return;
}
void take(int choice,int a[])
{
int x;
while(choice)
{
if(choice == 1)
{
system("cls");
printf("You want to take money:¥");
scanf("%d",&x);
a[0] -= x;
printf("Success!Your RMB:%d\n",a[0]);
exit(choice);
}
if(choice == 2)
{
system("cls");
printf("You want to take money:$");
scanf("%d",&x);
a[1] -= x;
printf("Success!Your RMB:%d\n",a[1]);
exit(choice);
}
system("cls");
printf("Pls input the sort of money which you want to take:\n");
printf("1:RMB 2:DOLLOR 0:CANCLE\n");
scanf("%d",&choice);
}
return;
}
void save(int choice,int a[])
{
int x;
while(choice)
{
if(choice == 1)
{
system("cls");
printf("You want to save money:¥");
scanf("%d",&x);
a[0] += x;
printf("Success!Your RMB:%d\n",a[0]);
exit(choice);
}
if(choice == 2)
{
system("cls");
printf("You want to save money:$");
scanf("%d",&x);
a[1] += x;
printf("Success!Your RMB:%d\n",a[1]);
exit(choice);
}
system("cls");
printf("Pls input the sort of money which you want to save:\n");
printf("1:RMB 2:DOLLOR 0:CANCLE\n");
scanf("%d",&choice);
}
return;
}
void examine(int choice,int a[2])
{
while(choice != 0)
{
if(choice == 1)
{
system("cls");
printf("RMB:%d\n",a[0]);
exit(choice);
}
else if(choice == 2)
{
system("cls");
printf("DOLLOR:%d\n",a[1]);
exit(choice);
}
system("cls");
printf("Pls input the sort of money which you want to search for:\n");
printf("1:RMB 2:DOLLOR 0:CANCLE\n");
scanf("%d",&choice);
}
return;
}
void main()
{

int i,password,choice,choice1,choice2,choice3;
int a[2]={RMB,DORROR};

printf(" ********************************************************\n");
printf(" * ATM *\n");
printf(" * Welcome to Feneration Bank *\n");
printf(" * ---------------- ----------------------- *\n");
printf(" * Owner:Excalibur Version Number: 1.0.1 *\n");
printf(" * ---------------- ----------------------- *\n");
printf(" * telephone: 028-81484128 *\n");
printf(" * ----------------------- *\n");
printf(" * *\n");
printf(" * If you have any question,Pls do not contact with us *\n");
printf(" ********************************************************\n");
printf("Pls insert your card and input password:");
scanf("%d",&password);
for(i = 0;i < 2;i++)
{
if(password == PASSWORD)
{
break;
}
printf("Your password is wrong,pls input again: ");
scanf("%d",&password);
}
if(i == 2)
{
printf("Sorry,you have input 3 times wrong password!\n");
printf("Your money has been confiscated!\n");
printf("Pls DO NOT contact with us! \n");
return;
}
system("cls");
printf("Pls input your requirement:\n");
printf("1: Examine balance 2:Saving 3:Take out 0:Cancle\n");
scanf("%d",&choice);
while(choice != 0)
{
if(choice == 1)
{
system("cls");
printf("Pls input the sort of money which you want to search for:\n");
printf("1:RMB 2:DOLLOR 0:CANCLE\n");
scanf("%d",&choice1);
examine(choice1,a);
}
if(choice == 2)
{
system("cls");
printf("Pls input the sort of money which you want to save:\n");
printf("1:RMB 2:DOLLOR 0:CANCLE\n");
scanf("%d",&choice2);
save(choice2,a);
}
if(choice == 3)
{
system("cls");
printf("Pls input the sort of money which you want to take:\n");
printf("1:RMB 2:DOLLOR 0:CANCLE\n");
scanf("%d",&choice3);
take(choice3,a);
}
system("cls");
printf("1: Examine balance 2:Saving 3:Take out 0:Cancle\n");
scanf("%d",&choice);
}

 

}

C语言后ATM第一次尝试