結果
| 問題 | No.24 数当てゲーム | 
| コンテスト | |
| ユーザー |  mono1977 | 
| 提出日時 | 2016-12-01 00:18:57 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 675 bytes | 
| コンパイル時間 | 645 ms | 
| コンパイル使用メモリ | 23,168 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-27 14:28:30 | 
| 合計ジャッジ時間 | 660 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                 scanf("%d %d %d %d %s",&ia,&ib,&ic,&id,yn);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include<stdio.h>
#include<string.h>
int main(){
	int n;
	int digit[10]={0};
	scanf("%d",&n);
	
	int ia,ib,ic,id;
	char yn[10];
	int i;
	for(i=0;i<n;i++){
		scanf("%d %d %d %d %s",&ia,&ib,&ic,&id,yn);
		
		if(strcmp(yn,"NO")==0){
			digit[ia]=-1;
			digit[ib]=-1;
			digit[ic]=-1;
			digit[id]=-1;			
		}else{
			if(digit[ia]!=-1){
				digit[ia]++;
			}
			if(digit[ib]!=-1){
				digit[ib]++;
			}
			if(digit[ic]!=-1){
				digit[ic]++;
			}
			if(digit[id]!=-1){
				digit[id]++;
			}
		}
	}
	
	int max=-1;
	for(i=0;i<10;i++){
		if(digit[i]>max){
			max = digit[i];
			ia = i;//ia再利用 Yesの数が一番多い数字を探す
		}
	}
	
	printf("%d\n",ia);
	
	return 0;
}
            
            
            
        