結果
問題 | No.79 過小評価ダメ・ゼッタイ |
ユーザー |
![]() |
提出日時 | 2025-03-05 14:28:27 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 698 bytes |
コンパイル時間 | 361 ms |
コンパイル使用メモリ | 25,472 KB |
実行使用メモリ | 8,612 KB |
最終ジャッジ日時 | 2025-03-05 14:28:29 |
合計ジャッジ時間 | 1,840 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 22 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%ld",&num); | ^~~~~~~~~~~~~~~~~ main.c:14:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d",&survey); | ^~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(){ // 同意見の集計 int agg[7]; int *aggp = agg; // アンケート数 long num = 0; scanf("%ld",&num); printf("%ld",num); // アンケート結果 for(long i = 0;i < num;i++){ int survey = 0; scanf("%d",&survey); // 同意見をまとめる for(int j = 0;j < 6;j++){ if(j + 1 == survey){ aggp[j] += 1; } } } printf("集計結果:"); for(int i = 0;i < 6;i++){ printf("%d ",aggp[i]); } printf("\n"); // 最も多い意見を探す int ans = 0; int tmp = 0; for(int i = 0;i < 6;i++){ printf("暫定:%d 比較:%d\n",ans,aggp[i]); if(aggp[i] >= tmp){ ans = i + 1; tmp = aggp[i]; } } printf("%d",ans); }