結果

問題 No.729 文字swap
ユーザー Piroty19Piroty19
提出日時 2018-09-26 16:07:28
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 222 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 54,120 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-19 07:40:50
合計ジャッジ時間 11,180 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:17: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘std::string*’ {aka ‘std::__cxx11::basic_string<char>*’} [-Wformat=]
    9 |         scanf("%s", &i);
      |                ~^   ~~
      |                 |   |
      |                 |   std::string* {aka std::__cxx11::basic_string<char>*}
      |                 char*
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%s", &i);
      |         ~~~~~^~~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d", &b);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<string>
#include<iostream>
int main()
{
	std::string i;
	int a, b;
	char c;
	scanf("%s", &i);
	scanf("%d", &a);
	scanf("%d", &b);
	c = i[a];
	i[a] = i[b];
	i[b] = c;
	std::cout << i;
	return 0;
}
0