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