結果
| 問題 | No.39 桁の数字を入れ替え | 
| コンテスト | |
| ユーザー |  tottoripaper | 
| 提出日時 | 2014-11-24 06:07:43 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                CE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 411 bytes | 
| コンパイル時間 | 161 ms | 
| コンパイル使用メモリ | 28,928 KB | 
| 最終ジャッジ日時 | 2024-11-14 18:55:31 | 
| 合計ジャッジ時間 | 728 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:20: error: ‘stoi’ is not a member of ‘std’; did you mean ‘atoi’?
   12 |     int res = std::stoi(ds);
      |                    ^~~~
      |                    atoi
main.cpp:16:38: error: ‘stoi’ is not a member of ‘std’; did you mean ‘atoi’?
   16 |             res = std::max(res, std::stoi(ds));
      |                                      ^~~~
      |                                      atoi
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%s", ds);
      |     ~~~~~^~~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <cstring>
#include <algorithm>
char ds[10];
int main(){
    scanf("%s", ds);
    
    int l = strlen(ds);
    int res = std::stoi(ds);
    for(int i=0;i<l;i++){
        for(int j=i+1;j<l;j++){
            std::swap(ds[i], ds[j]);
            res = std::max(res, std::stoi(ds));
            std::swap(ds[i], ds[j]);
        }
    }
    printf("%d\n", res);
}
            
            
            
        