結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
|
提出日時 | 2016-11-25 11:17:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 508 bytes |
コンパイル時間 | 1,734 ms |
コンパイル使用メモリ | 55,372 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-27 11:08:03 |
合計ジャッジ時間 | 1,638 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 5 |
ソースコード
#include <iostream> #include <string> using namespace std; string N; char get_max(string N){ char max = 0; for (int i=0;i<N.length();i++) { char target = N[i]; max = (target > max) ? target : max; } return max; } int main(){ cin >> N; char max = get_max(N); for (int i=0;i<N.length();i++) { if ((N[i]) != max) { for (int j=N.length()-1;j>=i+1;j--) { if (N[j] == max) { N[j] = N[i]; N[i] = max; } } } } cout<<N<<endl; }