#include<stdio.h>

#include<stdlib.h>


void chaxun(a3)

{

int b;

b = a3;

printf("您的余额:%d\n", b);

}


int qukuan(int a3)

{

int a=0, b=0;

printf("请输入要取的金额:\n");

scanf("%d", &a);

b = a3 - a;

if (b < 0)

{

printf("您的余额不足\n");

}

else

{


printf("请拿好你的%d元现金\n",a);

a3 = a3 - a;

}

return a3;


}


int gaimi(int a2)

{

int b, d, c = 1, e = 1;

while (e)

{

printf("请输入您的原密码\n");

scanf("%d", &d);

if (a2 == d)

{

e = 0;

}

else

{

e = 1;

printf("密码错误,请重新输入\n");

}

}

while (c)

{

printf("请输入您的新密码\n");

scanf("%d", &a2);

printf("请确认您的新密码\n");

scanf("%d", &b);

if (a2 == b)

{

printf("密码修改成功\n");

c = 0;

}

else

{

c = 1;

printf("俩次输入不一致,请重新修改\n");


}

}

return a2;

}


void quka()

{

printf("请收好您的卡片\n");

printf("谢谢,再见\n");

}


int cunkuan(int a3)

{

int k = 0;

printf("请输入您要存的金额\n");

scanf("%d", &k);

a3 = a3 + k;

printf("您的总金额为%d\n",a3);


return a3;

}


int main()

{

int b = 1, c, k, l, q = 1;

int a1 = 123456, a2 = 123456, a3 = 1000;

printf("欢迎使用atm机\n");

while (q)

{

printf("请输入您的帐号\n");

scanf("%d", &k);

printf("请输入密码\n");

scanf("%d", &l);

if (a1 == k&&a2 == l)

{

printf("您的账户余额为%d", a3);

q = 0;

}

else

{

printf("您的密码错误,请重新输入\n");

q = 1;

}

}

do{

printf("请选择\n");

printf("1查询\n");

printf("2取款\n");

printf("3修改密码\n");

printf("4取卡\n");

printf("5存款\n");

scanf("%d", &c);

switch (c)

{

case 1:

chaxun(a3);

break;

case 2:

a3 = qukuan(a3);

break;

case 3:

a2 = gaimi(a2);

break;

case 4:

quka();

break;

case 5:

cunkuan(a3);

break;

default:

break;

}

} while (c != 4);


return;

}