結果
| 問題 | No.24 数当てゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-09 15:25:54 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 760 bytes |
| コンパイル時間 | 319 ms |
| コンパイル使用メモリ | 22,016 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 00:03:50 |
| 合計ジャッジ時間 | 840 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:16:25: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[4]’ [-Wformat=]
16 | scanf("%s",&r[i]);
| ~^ ~~~~~
| | |
| | char (*)[4]
| char *
main.c:10:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d",&n);
| ^~~~~~~~~~~~~~
main.c:14:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d",&s[i][j]);
| ^~~~~~~~~~~~~~~~~~~~
main.c:16:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%s",&r[i]);
| ^~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include <string.h>
int main(void){
int n,i,j,s[6][4],count[10]={},max=0,anser=0;
char r[6][4]; /*文字列の配列*/
scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<4;j++){
scanf("%d",&s[i][j]);
}
scanf("%s",&r[i]);
}
/*二次元配列の中身確認*/
// for(i=0;i<n;i++){
// for(j=0;j<4;j++){
// printf("s[%d][%d]=%d\t",i,j,s[i][j]);
// }
// printf("r[%d]=%s\n",i,r[i]);
// }
for(i=0;i<n;i++){
if(strcmp(r[i],"NO")==0){
for(j=0;j<4;j++) count[s[i][j]]--;
}else{ for(j=0;j<4;j++) count[s[i][j]]++;
}
}
/*OK数がいくつあるか表示*/
//for(i=0;i<10;i++){printf("count[%d]=%d\n",i,count[i]);}
for(i=0;i<10;i++){
if(max <= count[i]){
max=count[i];
anser=i;
}
}
printf("%d",anser);
return 0;
}