题目链接:请点击
1 注意输出格式,句子之间两个空格(下图标黄)
2 当total=0时,就应该输出“Game Over”且不进行下面判断。
AC代码:
#include<iostream>
using namespace std;
int main(){
int T,K,total;
cin>>T>>K;
total=T;
for(int i=0;i<K;i++){
int n1,b,t,n2;
cin>>n1>>b>>t>>n2;
if(t>total){
cout<<"Not enough tokens. Total = "<<total<<"."<<endl;
continue;
}
if((b==1&&n2>n1)||(b==0&&n2<n1)) {
total=total+t;
cout<<"Win "<<t<<"! Total = "<<total<<"."<<endl;
}
if((b==1&&n2<n1)||(b==0&&n2>n1)) {
total=total-t;
cout<<"Lose "<<t<<". Total = "<<total<<"."<<endl;
}
if(total<=0) {
cout<<"Game Over."<<endl;
break;
}
}
return 0;
}