結果
| 問題 | No.39 桁の数字を入れ替え |
| コンテスト | |
| ユーザー |
soylio
|
| 提出日時 | 2020-01-18 13:34:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 467 bytes |
| コンパイル時間 | 547 ms |
| コンパイル使用メモリ | 63,744 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 13:27:38 |
| 合計ジャッジ時間 | 1,340 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <iostream>
using namespace std;
int main() {
int n, num[10];
bool end = false;
cin >> n;
int i = 1;
while (n > 0) {
num[i] = n % 10;
n /= 10;
i++;
}
i--;
num[0] = -1;
for (int j = i; j > 1; j--) {
int max = 0;
for (int k = 1; k < j; k++) {
if (num[max] < num[k])max = k;
}
if (num[j] < num[max]) {
int t = num[j];
num[j] = num[max];
num[max] = t;
break;
}
}
for (int j = i; j >0; j--) cout << num[j];
return 0;
}
soylio