結果
問題 | No.558 575検出するやつ |
ユーザー |
![]() |
提出日時 | 2025-03-07 17:50:56 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 750 bytes |
コンパイル時間 | 262 ms |
コンパイル使用メモリ | 25,472 KB |
実行使用メモリ | 8,608 KB |
最終ジャッジ日時 | 2025-03-07 17:50:58 |
合計ジャッジ時間 | 1,385 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 15 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:5:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | scanf("%s",str); | ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>#include <string.h>int main(void){char str[101];scanf("%s",str);char decision[4];int count = 0;for(int i = 0 ; i < 100;i++){if(str[i+2] == '\0'){break;}//文字列から文字を3文字取得strncpy(decision, str+i, 3);//取得した文字の最後に'\0(null文字)'を入れる。そうすることによって文字列の終端を示す。decision[3] = '\0';//取得した文字(3文字)を"cat"と同じか確認。strcmpを使って一致した場合0が返ってくる。if(strcmp(decision,"575") == 0){count++;}}if(count > 0){printf("YES");}else{printf("NO");}}