結果
問題 |
No.784 「,(カンマ)」
|
ユーザー |
![]() |
提出日時 | 2019-12-04 15:59:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 377 bytes |
コンパイル時間 | 116 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-30 15:48:29 |
合計ジャッジ時間 | 632 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%s", s); | ~~~~~^~~~~~~~~ main.cpp:20:23: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialized] 20 | printf("%c", buf[i]); | ~~~~~^ main.cpp:5:16: note: ‘buf’ declared here 5 | char s[256], buf[256]; | ^~~
ソースコード
#include <stdio.h> #include <string.h> int main() { char s[256], buf[256]; scanf("%s", s); size_t size = strlen(s)-1; int j=0; for (int i=size; i>=0; i--, j++) { if ((j+1)%4==0 && i!=size) { buf[j++]=','; buf[j]=s[i]; } else { buf[j]=s[i]; } } for (int i=j; i>=0; i--) { printf("%c", buf[i]); } printf("\n"); return 0; }