結果

問題 No.39 桁の数字を入れ替え
ユーザー tottoripapertottoripaper
提出日時 2014-11-24 06:07:43
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 411 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 29,056 KB
最終ジャッジ日時 2024-04-27 02:05:49
合計ジャッジ時間 664 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

#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);
}
0