結果

問題 No.24 数当てゲーム
ユーザー toto
提出日時 2025-03-27 09:19:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 753 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 30,848 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-27 09:19:22
合計ジャッジ時間 1,758 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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",&val);
      |         ~~~~~^~~~~~~~~~~
main.cpp:16:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                         scanf("%d",&p[i]);
      |                         ~~~~~^~~~~~~~~~~~
main.cpp:19:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |                 scanf("%s", str);
      |                 ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
	int val = 0;
	scanf("%d",&val);
	
	int judgment[10] = {0,0,0,0,0,0,0,0,0,0};
	
	int i = 0;
	while(i != val){
		int num[4];
		int *p = num;
		for(int i = 0;i < 4;i++){
			scanf("%d",&p[i]);
		}
		char str[4];
		scanf("%s", str);
        char *s = str;
        
		for(int i = 0;i < 10;i++){
			int count = 0;
			if(*s == 'N'){
				for(int j = 0;j < 4;j++){
					if(num[j] == i){
						judgment[i] = 1;
					}
				}
			}else if(*s == 'Y'){
				
				for(int j = 0;j < 4;j++){
					if(num[j] != i){
						count++;
					}
				}
				
				if(count == 4){
					judgment[i] = 1;
				}
			}
		}
		i++;
	}
	
	for(int i = 0;i < 10;i++){
		if(judgment[i] == 0){
			printf("%d",i);
		}
	}
}
0