結果

問題 No.431 死亡フラグ
ユーザー toto
提出日時 2025-03-27 10:46:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 27,904 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-27 10:47:00
合計ジャッジ時間 1,195 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |                 scanf("%d",&flg[i]);
      |                 ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(){
	// 死亡フラグと生存フラグを配列に格納
	int flg[4];
	for(int i = 0;i < 4;i ++){
		scanf("%d",&flg[i]);
	}
	
	// 生存フラグがたっているか判別
	if(flg[3] == 1){
		printf("SURVIVED");
	}else{
		// 死亡フラグが立っている数をカウント
		int count = 0;
		for(int i = 0;i < 3;i ++){
			if(flg[i] == 1){
				count++;
			}
		}
		// 死亡フラグの数で表示をする
		if(count >= 2){
			printf("DEAD");
		}else{
			printf("SURVIVED");
		}
	}
}
0