fork download
  1. #include <stdio.h>
  2.  
  3. int balance = 1000;
  4.  
  5. void deposit(int x) {
  6. balance += x;
  7. }
  8.  
  9. int withdraw(int y) {
  10. if (y <= balance) {
  11. balance -= y;
  12. return y;
  13. }else {
  14. return 0;
  15. }
  16. }
  17.  
  18. int check_balance(void) {
  19. return balance;
  20. }
  21.  
  22.  
  23. int main(void) {
  24. int x,y;
  25. int cash = 0;
  26.  
  27. scanf("%d %d",&x,&y);
  28.  
  29. deposit(x);
  30. printf("My account: %d\n", check_balance());
  31.  
  32. cash = withdraw(y);
  33. if(cash){
  34. printf("%d円引き出しました。\n",cash);
  35. } else {
  36. printf("お取り扱いできません。");
  37. }
  38.  
  39. printf("現在の残高:%d円\n", check_balance());
  40.  
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 5316KB
stdin
10000 12000
stdout
My account: 11000
お取り扱いできません。現在の残高:11000円