結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
|
提出日時 | 2018-06-15 14:57:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 570 bytes |
コンパイル時間 | 1,322 ms |
コンパイル使用メモリ | 156,888 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 14:49:05 |
合計ジャッジ時間 | 2,001 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%s", s); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long int ll; char s[100]; int n, k, m; int main() { cin.tie(0); ios::sync_with_stdio(false); scanf("%s", s); n = strlen(s); for (int i = 0; i < n; i++) { m = 0; for (int j = i +1; s[j]; j++) { if ((s[j]-'0') >= m) m = s[k=j]; } if (s[i] < m) { char t = s[k]; s[k] = s[i]; s[i] = t; break; } } printf("%s\n", s); return 0; }