結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
![]() |
提出日時 | 2017-07-25 20:15:17 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 488 bytes |
コンパイル時間 | 1,348 ms |
コンパイル使用メモリ | 158,732 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-09 17:18:57 |
合計ジャッジ時間 | 2,045 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 2 |
コンパイルメッセージ
main.cpp:2:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 2 | main(){ | ^~~~ main.cpp: In function ‘int main()’: main.cpp:4:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 4 | scanf("%s",S); | ~~~~~^~~~~~~~
ソースコード
#include<bits/stdc++.h>main(){char S[10];scanf("%s",S);for(int j = 0;j < strlen(S)-2;j++){int max = S[j]-'0';int index = j;for(int i = strlen(S)-1;i >= j+1;i--){if(S[i]-'0' > max){max = S[i] - '0';index = i;}}if(S[j]-'0' < max){char c = S[j];S[j] = S[index];S[index] = c;break;}}printf("%s",S);}