結果

問題 No.486 3 Straight Win(3連勝)
ユーザー Maeda
提出日時 2025-03-10 14:21:16
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 25,088 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-10 14:21:18
合計ジャッジ時間 1,721 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%s",game);
      |         ^~~~~~~~~~~~~~~~

ソースコード

diff #

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

void main(void){
	char game[1000] = "a";
	int eastWin = 0,westWin = 0;
	scanf("%s",game);
	int i = 0;
	while (game[i] != '\0'){
		if(game[i] == 'O'){
			westWin = 0;
			eastWin++;
		}else{
			eastWin = 0;
			westWin++;
		}
		if(eastWin == 3 || westWin == 3){
			break;
		}
		i++;
	}
	
	if((int)strlen(game) < 3 || eastWin != 3 && westWin != 3){
		printf("NA");
	}else if(eastWin == 3){
		printf("East");
	}else{
		printf("West");
	}

}
0