ATM.rar

  • qq277
    了解作者
  • Visual C++
    开发工具
  • 1KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 3
    下载次数
  • 2014-05-24 21:08
    上传日期
一个新学者的经典小程序,希望对初学者有所帮助
ATM.rar
  • ATM.c
    2KB
内容介绍
#include<stdio.h> int main() { int a=1000,b,n,m; for(;;) { printf("$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); printf("$ Please select key: $\n"); printf("$ 1.Query $\n"); printf("$ 2.Credit $\n"); printf("$ 3.Debit $\n"); printf("$ 4.Return $\n"); printf("$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); scanf("%d",&n); if(n==1) printf("You balance is %d.\n\n",a); else if(n==2) for(;;) { printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); printf("$ Please select credit money: $\n"); printf("$ 1.$50 $\n"); printf("$ 2.$100 $\n"); printf("$ 3.Return $\n"); printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); scanf("%d",&m); if(m==1) { if(a>=50) a-=50; else printf("You balance is not enough.\n"); } else if(m==2) { if(a>=100) a-=100; else printf("You balance is not enough.\n"); } else if(m==3) break; else printf("Input error!\n"); } else if(n==3) { for(;;) { printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); printf("$ Please select debit money: $\n"); printf("$ 1.$50 $\n"); printf("$ 2.$100 $\n"); printf("$ 3.$500 $\n"); printf("$ 4.$1000 $\n"); printf("$ 5.Return $\n"); printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); scanf("%d",&m); if(m==1) a+=50; else if(m==2) a+=100; else if(m==3) a+=500; else if(m==4) a+=1000; else if(m==5) break; else printf("Input error!\n"); } } else if(n==4) break; else printf("Input error!\n"); } return 0; }
评论
    相关推荐