当前位置:我的异常网» C语言 » 这是小弟我第一次用c语言写得程序,名叫简单的ATM机
这是小弟我第一次用c语言写得程序,名叫简单的ATM机,请大家给小弟我看看,另外哪位高手给小弟我详细解释下return的用法,通俗易懂点最好,多谢
www.myexceptions.net 网友分享于:2013-05-23 浏览:19次
这是我第一次用c语言写得程序,名叫简单的ATM机,请大家给我看看,另外谁给我详细解释下return的用法,通俗易懂点最好,谢谢!
#include
#include
main()
{
char Key,CMoney;
int password,password1=123,i=1,a=1000;
while(1)
{
do
{
printf("***************************\n");
printf("* Please select key *\n");
printf("* 1.password *\n");
printf("* 2.get money *\n");
printf("* 3.return *\n");
Key=getch();
}
while(Key!='1'&&Key!='2'&&Key!='3');
switch(Key)
{
case '1':
do
{
i++;
printf(" Please input password ");
scanf("%d",&password);
if(password!=password)
{
if(i>3)
{
printf("wrong!press any key exit....");
getch();
return(0);
}
else
puts("wrong,Try again ");
}
}
while(password!=password&&i<=3);/*如果密码不正确且输入次数小于等于3次,执行do循环语句*/
printf("OK!Press any key to continue...");/*密码正确返回初始界面开始操作*/
getch();
break;
case '2':
do
{
if(password!=password)
{
printf("please logging in,press any key continue...");
getch();
break;
}
else
{
printf("******************************\n");
printf("Please select;\n");
printf("* 1.$100 *\n");
printf("* 2.$200 *\n");
printf("* 3.$300 *\n");
printf("* 4.return *\n");
printf("*******************************\n");
CMoney=getch();
}
}
while(CMoney!='1'&&CMoney!='2'&&CMoney!='3'&&CMoney!='4');
switch(CMoney)
{
case '1':
a=a-100;
printf("****************************************\n");
printf("* Your Credit money is $100,thank you!*\n");
printf("* The balance is $%d. *\n",a);
printf("* press any key return...... *");
printf("******************************************");
getch();
break;
case '2':
a=a-200;
printf("****************************************\n");
printf("* Your Credit money is $200,thank you!*\n");
printf("* The balance is $%d. *\n",a);
printf("* press any key return...... *");
printf("******************************************");
getch();
break;
case '3':
a=a-300;
printf("****************************************\n");
printf("* Your Credit money is $300,thank you!*\n");
printf("* The balance is $%d. *\n",a);
printf("* press any key return...... *");
printf("******************************************");
getch();
break;
case '4':
break;
}
break;
case'3':
printf("******************************************");
printf("* Thank you for your using! *");
printf("* Goodbye! *");
printf("******************************************");
getch();
break;
}
}
}
完结!
另外有谁懂那个c语言的,给我通俗的解释一下下面的问题,我感激不尽:
文章评论