Coder

舒心、快乐,比什么都重要

1071 小赌怡情 (15 分)

#include <iostream>
#include <string>
using namespace std;
int main(){
    int T, K;
    cin >> T >> K;
    while (K--){
        int n1, b, t, n2;
        cin >> n1 >> b >> t >> n2;
        if (t > T) { //结果的输出前后顺序需要注意,好有就是格式很重要。
            cout << "Not " << "enough tokens.  Total = " << T << '.' << endl;
            continue;
        }
        if ((n1 > n2 && b == 0) || (n1 < n2 && b == 1)) {
            T += t;
            cout << "Win " << t << "!  Total = " << T << '.' << endl;
        }
        else {
            T -= t;
            cout << "Lose " << t << ".  Total = " << T << '.' << endl;
            if (T == 0){
                cout << "Game over.";
                break;
            }
        }
    }
    return 0;
}

 

posted @ 2019-04-20 19:33  H123K  阅读(112)  评论(0编辑  收藏  举报