結果

問題 No.293 4>7の世界
ユーザー eve__fuyukieve__fuyuki
提出日時 2018-03-13 23:26:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 51,924 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 22:24:12
合計ジャッジ時間 1,391 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:5: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     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