結果
問題 | No.9006 マルチバイト文字テスト(テスト用) |
ユーザー | T.Myze |
提出日時 | 2015-04-13 00:20:30 |
言語 | C90 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 683 bytes |
コンパイル時間 | 589 ms |
コンパイル使用メモリ | 24,340 KB |
実行使用メモリ | 4,500 KB |
最終ジャッジ日時 | 2023-09-17 19:50:31 |
合計ジャッジ時間 | 1,038 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
コンパイルメッセージ
main.c: In function ‘main’: main.c:18:2: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration] gets(str); ^~~~ fgets main.c: In function ‘invert_str’: main.c:33:15: warning: implicit declaration of function ‘calloc’ [-Wimplicit-function-declaration] ans = (char*)calloc(n + 1, sizeof(char)); ^~~~~~ main.c:33:15: warning: incompatible implicit declaration of built-in function ‘calloc’ main.c:33:15: note: include ‘<stdlib.h>’ or provide a declaration of ‘calloc’ main.c:10:1: +#include <stdlib.h> main.c:33:15: ans = (char*)calloc(n + 1, sizeof(char)); ^~~~~~ main.c:41:2: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration] free(ans); ^~~~ main.c:41:2: warning: incompatible implicit declaration of built-in function ‘free’ main.c:41:2: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’ /tmp/ccJR26MH.o: In function `main': main.c:(.text.startup+0x11): warning: the `gets' function is dangerous and should not be used.
ソースコード
/* 2015/04/12 tomohiro yonedu 入力に半角文字、全角文字が入り混じった文字列が与えられるので、 並びを逆順にした文字列を出力してください。 文字列はUTF-8(BOMなし)で与えられます。 */ #include <stdio.h> #include <string.h> void invert_str(char *str,int n); int main(void){ char str[1000]; int n = 0; gets(str); n = strlen(str); invert_str(str, n); return 0; } void invert_str(char *str,int n){ char *ans; int i,j; ans = (char*)calloc(n + 1, sizeof(char)); ans[n] = '\0'; for (i = n - 1, j = 0; i > -1; i--,j++){ ans[i] = str[j]; //printf("%c", str[i]); } printf("%s\n", ans); free(ans); }