結果
問題 |
No.495 (^^*) Easy
|
ユーザー |
![]() |
提出日時 | 2025-03-10 11:31:50 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 849 bytes |
コンパイル時間 | 430 ms |
コンパイル使用メモリ | 25,856 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-10 11:31:52 |
合計ジャッジ時間 | 1,297 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
コンパイルメッセージ
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> void main(void){ char str[1000000]; scanf("%s",str); char decision[100]; int left = 0, right = 0; for(int i = 0 ; i < 1000000;i++){ if(str[i+4] == '#'){ break; }else if(str[i+4] != ')'){ continue; } //文字列から文字を5文字取得 strncpy(decision, str+i, 5); //取得した文字の最後に'\0(null文字)'を入れる。そうすることによって文字列の終端を示す。 decision[5] = '\0'; //取得した文字(3文字)を"cat"と同じか確認。strcmpを使って一致した場合0が返ってくる。 if(strcmp(decision,"(^^*)") == 0){ left++; }else if(strcmp(decision,"(*^^)") == 0){ right++; } } printf("%d %d",left,right); }