其他分享
首页 > 其他分享> > PAT (Basic Level) Practice (中文)1071 小赌怡情 (15 分)

PAT (Basic Level) Practice (中文)1071 小赌怡情 (15 分)

作者:互联网

在这里插入图片描述
在这里插入图片描述
本题还是对输出格式有着要求,空格是两个需要注意,其他就是对情况的分类,没有太大难度,下面是完整的代码

#include<iostream>
using namespace std;
int main() {
 int T, K, n1, b, t, n2;
 cin >> T >> K;
 for (int i = 0; i < K; i++) {
  cin >> n1 >> b >> t >> n2;
  if (T == 0) {
   cout << "Game Over." << endl;
   break;
  }
  if (T < t) {
   cout << "Not enough tokens.  Total = " << T <<"." << endl;
   continue;
  }
  if ((n1 < n2&&b == 1) || (n1 > n2&&b == 0)) {
   T = t + T;
   cout << "Win " << t << "!  Total = " << T << "." << endl;
   continue;
  }
  else {
   T = T - t;
   cout << "Lose " << t << ".  Total = " << T << "." << endl;
   continue;
  }
 }
 return 0;
}

标签:小赌,PAT,cout,Level,int,cin,n1,n2
来源: https://blog.csdn.net/QTeemoQ/article/details/115440190