結果
| 問題 |
No.729 文字swap
|
| コンテスト | |
| ユーザー |
card_board01
|
| 提出日時 | 2018-09-24 17:23:41 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 418 bytes |
| コンパイル時間 | 350 ms |
| コンパイル使用メモリ | 26,880 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 11:59:52 |
| 合計ジャッジ時間 | 2,826 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 11 |
コンパイルメッセージ
main.c: In function 'swap':
main.c:6:12: warning: passing argument 1 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
6 | strcpy(tmp, *a);
| ^~~
| |
| char
In file included from main.c:2:
/usr/include/string.h:141:39: note: expected 'char * restrict' but argument is of type 'char'
141 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~^~~~~~
main.c:6:17: warning: passing argument 2 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
6 | strcpy(tmp, *a);
| ^~
| |
| char
/usr/include/string.h:141:70: note: expected 'const char * restrict' but argument is of type 'char'
141 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
main.c:7:12: warning: passing argument 1 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
7 | strcpy(*a, *b);
| ^~
| |
| char
/usr/include/string.h:141:39: note: expected 'char * restrict' but argument is of type 'char'
141 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~^~~~~~
main.c:7:16: warning: passing argument 2 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
7 | strcpy(*a, *b);
| ^~
| |
| char
/usr/include/string.h:141:70: note: expected 'const char * restrict' but argument is of type 'char'
141 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
main.c:8:12: warning: passing argument 1 of 'strcpy' makes pointer from intege
ソースコード
#include <stdio.h>
#include <string.h>
void swap(char *a, char *b) {
char tmp;
strcpy(tmp, *a);
strcpy(*a, *b);
strcpy(*b, tmp);
}
int main(void) {
int i, a, b;
char str[10];
int length;
length = sizeof(str) / sizeof(str[0]);
scanf("%s", str);
scanf("%d", &a); scanf("%d", &b);
swap(&str[a], &str[b]);
printf("%s", str);
return 0;
}
card_board01