fork download
  1. #include <stdio.h>
  2. #define slotCount(a,b) (a)/(b)+((a)%(b)!=0)
  3. int main()
  4. {
  5. int min, sec, kubun, price = 0, slotNum;
  6. int costTable[3][4] =
  7. {
  8. {1, 300, 6, 15}, {1, 240, 6, 12}, {1, 180, 6, 9}
  9. };
  10.  
  11. printf("通話時間を入力せよ(分 秒)- - - - >");
  12. scanf("%d %d", &min, &sec);
  13. printf("区分を入力せよ- - - - >" );
  14. scanf("%d", &kubun);
  15.  
  16. sec += (min - costTable[kubun - 1][0] ) * 60;
  17.  
  18. price =costTable[kubun - 1][1];
  19.  
  20. slotNum = slotCount(sec, costTable[kubun - 1][2]);
  21. price += slotNum * costTable[kubun - 1][3];
  22.  
  23. printf("あなたの通話料金は¥%dです\n", price);
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 2296KB
stdin
11 12
2
stdout
通話時間を入力せよ(分   秒)- - - - >区分を入力せよ- - - - >あなたの通話料金は¥1464です