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. }, *p = costTable[0];
  10.  
  11. printf("通話時間を入力せよ(分 秒)- - - - >");
  12. scanf("%d %d", &min, &sec);
  13. printf("区分を入力せよ- - - - >" );
  14. scanf("%d", &kubun);
  15. p += (sizeof(costTable[0]) / sizeof(int)) * (kubun - 1);
  16. if (min >= p[0])
  17. sec += (min - p[0] ) * 60;
  18. else
  19. sec = 0;
  20. slotNum = slotCount(sec, p[2]);
  21. price = p[1] + slotNum * p[3];
  22. printf("あなたの通話料金は¥%dです\n", price);
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 2252KB
stdin
11 12
2
stdout
通話時間を入力せよ(分   秒)- - - - >区分を入力せよ- - - - >あなたの通話料金は¥1464です