这道题要注意格式,比如
“Win %d! Total = %d.”
另外,如果余额为0,先输出Lose…… 紧接着输出Not enough
感叹号与T之间是两个空格。
#include <iostream>
using namespace std;
int main(){
int T,K;
int n1,b,t,n2;
cin>>T>>K;
for(int i=0;i<K;i++){
cin>>n1>>b>>t>>n2;
if(t>T){
printf("Not enough tokens. Total = %d.",T);
cout<<endl;
continue;
}
if(n1<n2&&(b==1)||(n1>n2&&(b==0))){
T+=t;
printf("Win %d! Total = %d.",t,T);
}else{
T-=t;
if(T==0){
printf("Lose %d. Total = %d.",t,T);
cout<<endl;
printf("Game Over.");
break;
}else{
printf("Lose %d. Total = %d.",t,T);
}
}
cout<<endl;
}
return 0;
}