結果
問題 | No.571 3人兄弟(その2) |
ユーザー |
![]() |
提出日時 | 2025-03-25 13:29:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 812 bytes |
コンパイル時間 | 377 ms |
コンパイル使用メモリ | 28,288 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2025-03-25 13:29:12 |
合計ジャッジ時間 | 3,599 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 2 |
other | RE * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:25: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=] 9 | scanf("%d%d",height[i],weight[i]); | ~^ ~~~~~~~~~ | | | | int* int main.cpp:9:27: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘int’ [-Wformat=] 9 | scanf("%d%d",height[i],weight[i]); | ~^ ~~~~~~~~~ | | | | int* int main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d%d",height[i],weight[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:9:22: warning: ‘weight’ is used uninitialized [-Wuninitialized] 9 | scanf("%d%d",height[i],weight[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:5:13: note: ‘weight’ declared here 5 | int weight[3]; | ^~~~~~ main.cpp:9:22: warning: ‘height’ is used uninitialized [-Wuninitialized] 9 | scanf("%d%d",height[i],weight[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:4:13: note: ‘height’ declared here 4 | int height[3]; | ^~~~~~
ソースコード
#include <stdio.h> int main(){ int height[3]; int weight[3]; char str[3] = {'A','B','C'}; for(int i = 0;i < 3;i ++){ scanf("%d%d",height[i],weight[i]); } for(int i = 0;i < 3;i ++){ for(int j = 0;j < 3;j ++){ if(height[i] > height[j]){ int tmp = height[i]; height[i] = height[j]; height[j] = tmp; tmp = weight[i]; weight[i] = weight[j]; weight[j] = tmp; char stmp = str[i]; str[i] = str[j]; str[j] = stmp; } } } for(int i = 0;i < 3;i ++){ for(int j = 0;j < 3;j ++){ if(height[i] == height[j]){ if(weight[i] > weight[j]){ int tmp = weight[i]; weight[i] = weight[j]; weight[j] = tmp; char stmp = str[i]; str[i] = str[j]; str[j] = stmp; } } } } for(int i = 0;i < 3;i ++){ printf("%c\n",str[i]); } }