#include<stdio.h>
#define n 7
#define m 12
int main()
{
char kamoku[m][n] = {"科目", "国語", "数学", "理科", "社会", "英語", "合計"};
char namae[m][n] = {"科目", "太郎", "次郎", "三郎", "四郎", "五郎", "花子", "春子", "夏子", "秋子", "冬子", "平均"};
int i, j, k;
// printf("%d %d\n", sizeof(kamoku),sizeof(kamoku[0]));
for (i = 0; i < m; i++) {}
double seiseki[m][m] = {{0, 0, 0, 0, 0, 0}, {0, 74, 93, 80, 73, 99}, {0, 78, 82, 78, 82, 74}, {0, 94, 68, 61, 71, 87}, {0, 82, 76, 96, 68, 78}, {0, 74, 79, 70, 61, 78}, {0, 89, 70, 70, 60, 72}, {0, 84, 96, 65, 75, 85}, {0, 91, 83, 89, 66, 75}, {0, 80, 83, 75, 71, 64}, {0, 86, 96, 93, 70, 62}};
for (i = 0; i < m + 1; i++) {
for (j = 0; j < n - 1; j++) {}
}
printf("┌───┬──┬──┬──┬──┬──┬───┐\n");//一行目,科目名が3文字なのでそれぞれにスペースを入れて罫線をそろえる! for (i = 1; i < n - 1; ++i) {
}
printf("│ %s │\n", kamoku
[6]); printf("├───┼──┼──┼──┼──┼──┼───┤\n");//三行目 for (i = 1; i < 11; i++) { //成績表示
for (j = 1; j < n - 1; j++) {
printf("│%4.0f", seiseki
[i
][j
]); seiseki[i][0] += seiseki[i][j]; //横計
}
printf("│%6.0f│\n", seiseki
[i
][0]); printf("├───┼──┼──┼──┼──┼──┼───┤\n");//三行目をコピー }
for (j = 1; j < n - 1; j++) {
for (i = 1; i < m - 1; i++) {
seiseki[0][j] += seiseki[i][j]; //縦計
}
printf("│%4.1f", seiseki
[0][j
] / (m
- 2)); //科目平均 seiseki[0][0] += seiseki[0][j]; //総点
}
printf("│%6.1f│\n", seiseki
[0][0] / (m
- 2)); //合計平均
printf("└───┴──┴──┴──┴──┴──┴───┘\n");
for (i = 1; i <= 5; ++i) {
printf("\n%s\n順位 名前 成績\n", kamoku
[i
]); int min = seiseki[1][i];
int max = min;
for (j = 1; j < m - 1; ++j) {
if (min > seiseki[j][i])min = seiseki[j][i];
if (max < seiseki[j][i])max = seiseki[j][i];
}
int juni = 0;
for (j = max; j >= min; --j)
for (k = 1; k < m - 1; ++k)
if (seiseki
[k
][i
] == j
)printf("%2d %6s %3d\n", ++juni
, namae
[k
], j
); }
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2RlZmluZSBuIDcKI2RlZmluZSBtIDEyCgppbnQgbWFpbigpCnsKICBjaGFyIGthbW9rdVttXVtuXSA9IHsi56eR55uuIiwgIuWbveiqniIsICLmlbDlraYiLCAi55CG56eRIiwgIuekvuS8miIsICLoi7Hoqp4iLCAi5ZCI6KiIIn07CiAgY2hhciBuYW1hZVttXVtuXSA9IHsi56eR55uuIiwgIuWkqumDjiIsICLmrKHpg44iLCAi5LiJ6YOOIiwgIuWbm+mDjiIsICLkupTpg44iLCAi6Iqx5a2QIiwgIuaYpeWtkCIsICLlpI/lrZAiLCAi56eL5a2QIiwgIuWGrOWtkCIsICLlubPlnYcifTsKICBpbnQgaSwgaiwgazsKICAvLyBwcmludGYoIiVkICVkXG4iLCBzaXplb2Yoa2Ftb2t1KSxzaXplb2Yoa2Ftb2t1WzBdKSk7CiAgZm9yIChpID0gMDsgaSA8IG07IGkrKykge30KICBkb3VibGUgc2Vpc2VraVttXVttXSA9IHt7MCwgMCwgMCwgMCwgMCwgMH0sIHswLCA3NCwgOTMsIDgwLCA3MywgOTl9LCB7MCwgNzgsIDgyLCA3OCwgODIsIDc0fSwgezAsIDk0LCA2OCwgNjEsIDcxLCA4N30sIHswLCA4MiwgNzYsIDk2LCA2OCwgNzh9LCB7MCwgNzQsIDc5LCA3MCwgNjEsIDc4fSwgezAsIDg5LCA3MCwgNzAsIDYwLCA3Mn0sIHswLCA4NCwgOTYsIDY1LCA3NSwgODV9LCB7MCwgOTEsIDgzLCA4OSwgNjYsIDc1fSwgezAsIDgwLCA4MywgNzUsIDcxLCA2NH0sIHswLCA4NiwgOTYsIDkzLCA3MC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vOKUgOKUgOKUvOKUgOKUgOKUvOKUgOKUgOKUvOKUgOKUgOKUgOKUpFxuIik7Ly/kuInooYznm67jgpLjgrPjg5Tjg7wKICB9CiAgcHJpbnRmKCLilILjgIAlcyIsIG5hbWFlWzExXSk7CiAgZm9yIChqID0gMTsgaiA8IG4gLSAxOyBqKyspIHsKICAgIGZvciAoaSA9IDE7IGkgPCBtIC0gMTsgaSsrKSB7CiAgICAgIHNlaXNla2lbMF1bal0gKz0gc2Vpc2VraVtpXVtqXTsgLy/nuKboqIgKICAgIH0KICAgIHByaW50Zigi4pSCJTQuMWYiLCBzZWlzZWtpWzBdW2pdIC8gKG0gLSAyKSk7IC8v56eR55uu5bmz5Z2HCiAgICBzZWlzZWtpWzBdWzBdICs9IHNlaXNla2lbMF1bal07IC8v57eP54K5CiAgfQogIHByaW50Zigi4pSCJTYuMWbilIJcbiIsIHNlaXNla2lbMF1bMF0gLyAobSAtIDIpKTsgLy/lkIjoqIjlubPlnYcKCiAgcHJpbnRmKCLilJTilIDilIDilIDilLTilIDilIDilLTilIDilIDilLTilIDilIDilLTilIDilIDilLTilIDilIDilLTilIDilIDilIDilJhcbiIpOwoKCiAgZm9yIChpID0gMTsgaSA8PSA1OyArK2kpIHsKICAgIHByaW50ZigiXG4lc1xu6aCG5L2N44CA5ZCN5YmN44CA5oiQ57i+XG4iLCBrYW1va3VbaV0pOwogICAgaW50IG1pbiA9IHNlaXNla2lbMV1baV07CiAgICBpbnQgbWF4ID0gbWluOwogICAgZm9yIChqID0gMTsgaiA8IG0gLSAxOyArK2opIHsKICAgICAgaWYgKG1pbiA+IHNlaXNla2lbal1baV0pbWluID0gc2Vpc2VraVtqXVtpXTsKICAgICAgaWYgKG1heCA8IHNlaXNla2lbal1baV0pbWF4ID0gc2Vpc2VraVtqXVtpXTsKICAgIH0KICAgIGludCBqdW5pID0gMDsKICAgIGZvciAoaiA9IG1heDsgaiA+PSBtaW47IC0taikKICAgICAgZm9yIChrID0gMTsgayA8IG0gLSAxOyArK2spCiAgICAgICAgaWYgKHNlaXNla2lba11baV0gPT0gailwcmludGYoIiUyZCAgICU2cyAlM2RcbiIsICsranVuaSwgbmFtYWVba10sIGopOwogIH0KICByZXR1cm4gMDsKfQo=