結果
| 問題 |
No.9006 マルチバイト文字テスト(テスト用)
|
| ユーザー |
T.Myze
|
| 提出日時 | 2015-04-13 00:20:30 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 683 bytes |
| コンパイル時間 | 133 ms |
| コンパイル使用メモリ | 21,376 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 14:05:53 |
| 合計ジャッジ時間 | 812 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:18:9: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
18 | gets(str);
| ^~~~
| fgets
main.c: In function ‘invert_str’:
main.c:33:22: warning: implicit declaration of function ‘calloc’ [-Wimplicit-function-declaration]
33 | ans = (char*)calloc(n + 1, sizeof(char));
| ^~~~~~
main.c:10:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘calloc’
9 | #include <string.h>
+++ |+#include <stdlib.h>
10 |
main.c:33:22: warning: incompatible implicit declaration of built-in function ‘calloc’ [-Wbuiltin-declaration-mismatch]
33 | ans = (char*)calloc(n + 1, sizeof(char));
| ^~~~~~
main.c:33:22: note: include ‘<stdlib.h>’ or provide a declaration of ‘calloc’
main.c:41:9: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
41 | free(ans);
| ^~~~
main.c:41:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
main.c:41:9: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
main.c:41:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
/usr/bin/ld: /tmp/ccOQPpT7.o: in function `main':
main.c:(.text.startup+0x26): 警告: 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);
}
T.Myze