結果

問題 No.345 最小チワワ問題
ユーザー a2011404
提出日時 2017-03-23 14:03:49
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 452 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 20,864 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 20:37:23
合計ジャッジ時間 954 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%s",s);
      |         ^~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>			
#include<string.h>
		
int main(void) {			

	int i,j,min=100,w=0,count=0;
	char s[100];
			
	scanf("%s",s);

	for(i=0;i<strlen(s);i++){
		if(s[i]=='c'){
			count++;
			for(j=i+1;j<strlen(s);j++){
				if(s[j]== 'w'){
					count++;
					w++;
					if(w==2){
						w=0;
						if(min>count){
							min=count;
							count=0;
							break;
						}
					}
				}else	count++;
			}
		}
	}
	printf("%d",(min!=100? min : -1));
	return 0;		
}
0