結果

問題 No.256 桁の数字を入れ替え (2)
コンテスト
ユーザー r2en_
提出日時 2017-03-19 14:06:07
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 491 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 565 ms
コンパイル使用メモリ 90,260 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-26 06:00:55
合計ジャッジ時間 1,138 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:16:22: warning: 'cnt' may be used uninitialized [-Wmaybe-uninitialized]
   16 |     for(int i = 0; i < cnt; i++){ vec.push_back(data[i]); }
      |                    ~~^~~~~
main.cpp:7:13: note: 'cnt' was declared here
    7 |     int n,m,cnt;
      |             ^~~

ソースコード

diff #
raw source code

#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