結果
| 問題 |
No.39 桁の数字を入れ替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-15 15:09:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 435 bytes |
| コンパイル時間 | 126 ms |
| コンパイル使用メモリ | 22,784 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 14:49:10 |
| 合計ジャッジ時間 | 786 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%s", s);
| ~~~~~^~~~~~~~~
ソースコード
#include <stdio.h>
#include <string.h>
char s[100];
int n, k, m;
int main() {
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]-'0';
if (s[i]-'0' < m) {
char t = s[k];
s[k] = s[i];
s[i] = t;
//break;
}
}
printf("%s\n", s);
}