結果

問題 No.197 手品
ユーザー taro305
提出日時 2016-07-04 09:51:09
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 721 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 13:33:16
合計ジャッジ時間 1,618 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:10:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%s", before);
      |         ^~~~~~~~~~~~~~~~~~~
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%s", after);
      |         ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

int main(void)
{
	char before[4], after[4];
	char tmp;
	int i, n, count = 0;

	scanf("%s", before);
	scanf("%d", &n);
	scanf("%s", after);

	for(i = 0; i < 3; i++){
		if(before[i] == 'o')
			count++;
		if(after[i] == 'o')
			count--;
	}
	
	if(n == 0){
		if(strcmp(before, after) == 0)
			printf("FAILURE");
		else
			printf("SUCCESS");
	}
	else if(n == 1){
		if(count != 0)
			printf("SUCCESS");
		else{
			tmp = after[2];
			after[2] = after[0];
			after[0] = tmp;
			if(strcmp(before, after) == 0)	
				printf("SUCCESS");
			else	
				printf("FAILURE");
		}
	}
	else if(n >= 2){
		if(count != 0)
			printf("SUCCESS");
		else
			printf("FAILURE");
	}
	printf("\n");
	return 0;
}

0