Submission #19556
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include<stdio.h> typedef struct { char name[21]; int jap; int math; int eng; int sum; }Student; int main(){ int n,i,s,j; scanf ( "%d" ,&n); Student a[11]; for (i=0;i<n;i++){ scanf ( "%s %d %d %d" ,a[i].name,&a[i].jap,&a[i].math,&a[i].eng); a[i].sum=a[i].jap+a[i].math+a[i].eng; } for (i=0;i<n;i++){ for (j=0;j<n-i-1;j++){ if (a[j].sum<a[j+1].sum){ Student temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } else if (a[j].sum==a[j+1].sum){ s= strcmp (a[j].name,a[j+1].name); if (s>0){ Student temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } } for (i=0;i<n;i++){ printf ( "%d %s %d\n" ,i+1,a[i].name,a[i].sum); } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0054 - てすと |
ユーザー名 | r1705 |
投稿日時 | 2017-06-15 19:07:34 |
言語 | C |
状態 | Accepted |
得点 | 2 |
ソースコード長 | 716 Byte |
最大実行時間 | 12 ms |
最大メモリ使用量 | 428 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 2 / 2 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in1.txt | AC | 12 ms | 380 KB |
1
|
in2.txt | AC | 12 ms | 304 KB |
1
|
in3.txt | AC | 10 ms | 328 KB |
1
|
in4.txt | AC | 12 ms | 384 KB |
1
|
in5.txt | AC | 10 ms | 428 KB |
1
|