Advertisement
cd62131

sum

Apr 14th, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <limits.h>
  3. int main(void) {
  4.   int i, j, max = INT_MIN, max_no;
  5.   int score[4][2];
  6.   int sum[4];
  7.   char kyouka[2][7] = {"英語", "数学"};
  8.   for (i = 0; i < 4; i++) {
  9.     for (j = 0; j < 2; j++) {
  10.       printf("%d人目の%sの点数は?", i + 1, kyouka[j]);
  11.       scanf("%d", &score[i][j]);
  12.     }
  13.     sum[i] = score[i][0] + score[i][1];
  14.   }
  15.   for (i = 0; i < 4; i++) {
  16.     if (max < sum[i]) {
  17.       max = sum[i];
  18.       max_no = i;
  19.     }
  20.   }
  21.   puts("2教科の合計が高い人は");
  22.   printf("%d人目で、英語%d点、数学%d点、合計点%d点です。\n",
  23.       max_no + 1, score[max_no][0], score[max_no][1], max);
  24.   return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement