#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 juniDisp, juniInternal = 1;
for (j = max; j >= min; --j)
{
juniDisp = juniInternal;
for (k = 1; k < m - 1; ++k)
{
if (seiseki[k][i] == j)
{
++juniInternal;
printf("%2d %6s %3d\n", juniDisp
, namae
[k
], j
); }
}
}
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2RlZmluZSBuIDcKI2RlZmluZSBtIDEyCgppbnQgbWFpbigpCnsKICAgIGNoYXIga2Ftb2t1W21dW25dID0geyLnp5Hnm64iLCAi5Zu96KqeIiwgIuaVsOWtpiIsICLnkIbnp5EiLCAi56S+5LyaIiwgIuiLseiqniIsICLlkIjoqIgifTsKICAgIGNoYXIgbmFtYWVbbV1bbl0gPSB7IuenkeebriIsICLlpKrpg44iLCAi5qyh6YOOIiwgIuS4iemDjiIsICLlm5vpg44iLCAi5LqU6YOOIiwgIuiKseWtkCIsICLmmKXlrZAiLCAi5aSP5a2QIiwgIueni+WtkCIsICLlhqzlrZAiLCAi5bmz5Z2HIn07CiAgICBpbnQgaSwgaiwgazsKICAgIC8vIHByaW50ZigiJWQgJWRcbiIsIHNpemVvZihrYW1va3UpLHNpemVvZihrYW1va3VbMF0pKTsKICAgIGZvciAoaSA9IDA7IGkgPCBtOyBpKyspIHt9CiAgICBkb3VibGUgc2Vpc2VraVttXVttXSA9IHt7MCwgMCwgMCwgMCwgMCwgMH0sIHswLCA3NCwgOTMsIDgwLCA3MywgOTl9LCB7MCwgNzgsIDgyLCA3OCwgODIsIDc0fSwgezAsIDk0LCA2OCwgNjEsIDcxLCA4N30sIHswLCA4MiwgNzYsIDk2LCA2OCwgNzh9LCB7MCwgNzQsIDc5LCA3MCwgNjEsIDc4fSwgezAsIDg5LCA3MCwgNzAsIDYwLCA3Mn0sIHswLCA4NCwgOTYsIDY1LCA3NSwgODV9LCB7MCwgOTEsIDgzLCA4OSwgNjYsIDc1fSwgezAsIDgwLCA4MywgNzUsIDcxLCA2NH0sIHswLCA4NiwgOTYsIDkzLCA3MCwgNjJ9fTsKICAgIGZvciAoaSA9IDA7IGkgPCBtICsgMTsgaSsrKQogICAgewogICAgICAgIGZvciAoaiA9IDA7IGogPCBuIC0gMTsgaisrKSB7fQogICAgfQogICAgcHJpbnRmKCLilIzilIDilIDilIDilKzilIDilIDilKzilIDilIDilKzilIDilIDilKzilIDilIDilKzilIDilIDilKzilIDilIDilIDilJBcbiIpOy8v5LiA6KGM55uuLOenkeebruWQjeOBjO+8k+aWh+Wtl+OBquOBruOBp+OBneOCjOOBnuOCjOOBq+OCueODmuODvOOCueOCkuWFpeOCjOOBpue9q+e3muOCkuOBneOCjeOBiOOCiyEKICAgIHByaW50Zigi4pSCIik7Ly/kuozooYznm64KICAgIHByaW50Zigi56eR55uu5ZCNIiwga2Ftb2t1WzBdKTsKICAgIGZvciAoaSA9IDE7IGkgPCBuIC0gMTsgKytpKQogICAgewogICAgICAgIHByaW50Zigi4pSCJXMiLCBrYW1va3VbaV0pOwogICAgfQogICAgcHJpbnRmKCLilIIgJXMg4pSCXG4iLCBrYW1va3VbNl0pOwogICAgcHJpbnRmKCLilJzilIDilIDilIDilLzilIDilIDilLzilIDilIDilLzilIDilIDilLzilIDilIDilLzilIDilIDilLzilIDilIDilIDilKRcbiIpOy8v5LiJ6KGM55uuCiAgICBmb3IgKGkgPSAxOyBpIDwgMTE7IGkrKykgICAvL+aIkOe4vuihqOekugogICAgewogICAgICAgIHByaW50Zigi4pSC44CAJXMiLCBuYW1hZVtpXSk7CiAgICAgICAgZm9yIChqID0gMTsgaiA8IG4gLSAxOyBqKyspCiAgICAgICAgewogICAgICAgICAgICBwcmludGYoIuKUgiU0LjBmIiwgc2Vpc2VraVtpXVtqXSk7CiAgICAgICAgICAgIHNlaXNla2lbaV1bMF0gKz0gc2Vpc2VraVtpXVtqXTsgLy/mqKroqIgKICAgICAgICB9CiAgICAgICAgcHJpbnRmKCLilIIlNi4wZuKUglxuIiwgc2Vpc2VraVtpXVswXSk7CiAgICAgICAgcHJpbnRmKCLilJzilIDilIDilIDilLzilIDilIDilLzilIDilIDilLzilIDilIDilLzilIDilIDilLzilIDilIDilLzilIDilIDilIDilKRcbiIpOy8v5LiJ6KGM55uu44KS44Kz44OU44O8CiAgICB9CiAgICBwcmludGYoIuKUguOAgCVzIiwgbmFtYWVbMTFdKTsKICAgIGZvciAoaiA9IDE7IGogPCBuIC0gMTsgaisrKQogICAgewogICAgICAgIGZvciAoaSA9IDE7IGkgPCBtIC0gMTsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgc2Vpc2VraVswXVtqXSArPSBzZWlzZWtpW2ldW2pdOyAvL+e4puioiAogICAgICAgIH0KICAgICAgICBwcmludGYoIuKUgiU0LjFmIiwgc2Vpc2VraVswXVtqXSAvIChtIC0gMikpOyAvL+enkeebruW5s+WdhwogICAgICAgIHNlaXNla2lbMF1bMF0gKz0gc2Vpc2VraVswXVtqXTsgLy/nt4/ngrkKICAgIH0KICAgIHByaW50Zigi4pSCJTYuMWbilIJcbiIsIHNlaXNla2lbMF1bMF0gLyAobSAtIDIpKTsgLy/lkIjoqIjlubPlnYcKCiAgICBwcmludGYoIuKUlOKUgOKUgOKUgOKUtOKUgOKUgOKUtOKUgOKUgOKUtOKUgOKUgOKUtOKUgOKUgOKUtOKUgOKUgOKUtOKUgOKUgOKUgOKUmFxuIik7CgoKICAgIGZvciAoaSA9IDE7IGkgPD0gNTsgKytpKQogICAgewogICAgICAgIHByaW50ZigiXG4lc1xu6aCG5L2N44CA5ZCN5YmN44CA5oiQ57i+XG4iLCBrYW1va3VbaV0pOwogICAgICAgIGludCBtaW4gPSBzZWlzZWtpWzFdW2ldOwogICAgICAgIGludCBtYXggPSBtaW47CiAgICAgICAgZm9yIChqID0gMTsgaiA8IG0gLSAxOyArK2opCiAgICAgICAgewogICAgICAgICAgICBpZiAobWluID4gc2Vpc2VraVtqXVtpXSltaW4gPSBzZWlzZWtpW2pdW2ldOwogICAgICAgICAgICBpZiAobWF4IDwgc2Vpc2VraVtqXVtpXSltYXggPSBzZWlzZWtpW2pdW2ldOwogICAgICAgIH0KICAgICAgICBpbnQganVuaURpc3AsIGp1bmlJbnRlcm5hbCA9IDE7CiAgICAgICAgZm9yIChqID0gbWF4OyBqID49IG1pbjsgLS1qKQogICAgICAgIHsKICAgICAgICAgICAganVuaURpc3AgPSBqdW5pSW50ZXJuYWw7CiAgICAgICAgICAgIGZvciAoayA9IDE7IGsgPCBtIC0gMTsgKytrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoc2Vpc2VraVtrXVtpXSA9PSBqKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICsranVuaUludGVybmFsOwogICAgICAgICAgICAgICAgICAgIHByaW50ZigiJTJkICAgJTZzICUzZFxuIiwganVuaURpc3AsIG5hbWFlW2tdLCBqKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAwOwp9Cg==