結果

問題 No.293 4>7の世界
ユーザー eve__fuyuki
提出日時 2018-03-13 23:26:49
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 54,616 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 12:36:46
合計ジャッジ時間 1,346 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:5: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   30 |     if(ans) cout << B_ << endl;
      |     ^~

ソースコード

diff #

#include<iostream>
using namespace std;
bool great(int x,int y){
    if(x == 4 && y == 7) return false;
    if(y == 4 && x == 7) return true;
    else return x < y;
}
int main(){
    int A,B,A_,B_;
    bool ans;
    int numA[10] = {};
    int numB[10] = {};
    cin >> A >> B;
    A_ = A;
    B_ = B;
    for(int i=9;i>=0;i--){
        numA[i] = A%10;
        A /= 10;
        numB[i] = B%10;
        B /= 10;
    }
    for(int i=0;i<10;i++){
        if(numA[i] == numB[i]) continue;
        else if(great(numA[i],numB[i])){
            ans = true;
        }
        else ans = false;
        break;
    }
    if(ans) cout << B_ << endl;
    else cout << A_ << endl;
    return 0;
}
0