結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-08-06 04:10:09 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 462 bytes |
コンパイル時間 | 249 ms |
コンパイル使用メモリ | 21,376 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 02:42:19 |
合計ジャッジ時間 | 1,231 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 14 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:10:5: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | fgets(buf, sizeof(buf), stdin); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> int main(void){ char buf[100] = {}; char str[] = "cww"; int i = 0, j = 0, x; fgets(buf, sizeof(buf), stdin); while(buf[i] != '\0'){ if(buf[i] == str[j]){ j++; if(j == 1){ x = i; } if(j == (sizeof(str)) - 1){ printf("%d\n", i-x+1); exit(0); } } i++; } printf("-1\n"); return 0; }