結果

問題 No.345 最小チワワ問題
ユーザー suppy193suppy193
提出日時 2016-04-08 15:27:08
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 20,480 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 23:27:24
合計ジャッジ時間 1,080 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,812 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 0 ms
6,944 KB
testcase_08 AC 0 ms
6,944 KB
testcase_09 AC 0 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 0 ms
6,944 KB
testcase_13 AC 0 ms
6,944 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 0 ms
6,940 KB
testcase_21 AC 0 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 0 ms
6,940 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%s", str);
      |         ^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void) {
	char str[101];
	int i, count;
	int flag_c = 0, flag_w1 = 0, flag_w2 = 0;
	
	scanf("%s", str);
	i = 0;
	count = 0;
	while(str[i] != '\0'){
		if(str[i] == 'c'){
			count++;
			flag_c = 1;
		}
		else if(flag_c == 1 && flag_w1 == 0 && str[i] == 'w'){
			flag_w1 = 1;
			count++;
		}
		else if(flag_c == 1 && flag_w1 == 1 && flag_w2 == 0 && str[i] == 'w'){
			count++;
			flag_w2 = 1;
			flag_c = 0;
			flag_w1 = 0;
		}
		else if(flag_c == 1 || flag_w1 == 1){
			count++;
		}
		i++;
	}
	if(flag_w2 == 1){
		printf("%d\n", count);
	}
	else{
		printf("-1\n");
	}

    return 0;
}
0