第一次部分错误
原因:a,b为int型,但是都若2的31次方,相加可能就为double的范围了,超过了int的范围,故不能设为int型
解决:a,b,c设置为double型
跟大佬学会了控制空格/换行在中间输出而不在最后输出的方法
使用flag变量记录输出
在没输出前让flag=0,输出一次后则让flag=1,若flag=1则先输出换行
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
string s;
int main(){
double a,b,c;
int n,t=1;
cin>>n;
int flag=0;
while(n--){
if(flag==1) cout<<endl;
cin>>a>>b>>c;
if(a+b>c)
cout<<"Case #"<<t++<<":"<<" true";
else
cout<<"Case #"<<t++<<":"<<" false";
flag=1;
}
return 0;
}