結果

問題 No.729 文字swap
ユーザー nisshimo
提出日時 2019-01-18 23:34:49
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 259 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 22,144 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-07 04:05:25
合計ジャッジ時間 637 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%s", word);
      |     ~~~~~^~~~~~~~~~~~
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%d", &i);
      |     ~~~~~^~~~~~~~~~
main.cpp:11:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |     scanf("%d", &j);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
using namespace std;

int main(void)
{
    int i, j;
    char tmp;
    char word[20];
    scanf("%s", word);
    scanf("%d", &i);
    scanf("%d", &j);

    tmp = word[j];
    word[j] = word[i];
    word[i] = tmp;

    printf("%s", word);
}
0