結果

問題 No.256 桁の数字を入れ替え (2)
ユーザー r2en_r2en_
提出日時 2017-03-19 14:06:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 75,468 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 07:22:52
合計ジャッジ時間 1,378 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:7:13: 警告: ‘cnt’ may be used uninitialized [-Wmaybe-uninitialized]
    7 |     int n,m,cnt;
      |             ^~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,m,cnt;
    vector<int>vec;
    vector<int>::iterator ip;
    int data[10] = {};
    scanf("%d",&n);
    while(n){
        m = n % 10; data[cnt] = m;
        n/=10; cnt++;
    }
    for(int i = 0; i < cnt; i++){ vec.push_back(data[i]); }
    sort(vec.begin(),vec.end(),greater<int>());
    ip = vec.begin();
    while(ip != vec.end()){ cout << *ip; ip++;}
    cout << "\n";
    return 0;
}
0