結果
問題 |
No.400 鏡
|
ユーザー |
|
提出日時 | 2018-05-20 15:33:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 954 bytes |
コンパイル時間 | 116 ms |
コンパイル使用メモリ | 23,808 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 14:41:26 |
合計ジャッジ時間 | 660 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 4 WA * 4 |
コンパイルメッセージ
main.cpp:1: warning: "_GNU_SOURCE" redefined 1 | #define _GNU_SOURCE | <command-line>: note: this is the location of the previous definition main.cpp: In function ‘int main()’: main.cpp:49:10: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 49 | fgets(s, 1025, stdin); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#define _GNU_SOURCE #include<stdio.h> #include<string.h> void reverse(char* s) { const size_t l = strlen(s); for (int i = 0 ; i < l ; i++) { char t = s[i]; s[i] = s[l-1-i]; s[l-1-i] = s[i]; } } void flip(char* s) { const size_t l = strlen(s); for (int i = 0 ; i < l ; i++) { switch (s[i]) { case '<': s[i] = '>'; break; case '>': s[i] = '<'; break; default: break; } } } void smash_newline(char* s) { const size_t l = strlen(s); for (int i = l-1 ; i > 0 ; i--) { switch(s[i]) { case '\r': s[i] = '\0'; break; case '\n': s[i] = '\0'; default: break; } } } int main(void) { char s[1025]; fgets(s, 1025, stdin); smash_newline(s); flip(s); reverse(s); puts(s); }