hahaha,我又来抄代码啦。。。
原博主写的很好:https://blog.csdn.net/yanduoxuan/article/details/81194595
两种解法,拒绝大数模拟,借鉴一下:
#include<iostream>
using namespace std;
int main(){
long long a,b,c;
int N,i;
scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%lld %lld %lld",&a ,&b ,&c);
cout<<"Case #"<<i+1<<": ";
long long temp=a+b;
if(a>0&&b>0&&temp<0) cout<<"true"<<endl;
else if(a<0&&b<0&& temp>=0) cout<<"false"<<endl;
else if(temp>c)cout<<"true"<<endl;
else cout<<"false"<<endl;
}
system("pause");
return 0;
}
long double实际能存储的范围大于long long 但是精度低,放在这里也能AC:
注意输入使用“%llf"哦!
#include<iostream>
using namespace std;
long double a, b, c;
int T;
int main() {
scanf("%d", &T);
for (int i = 1; i <= T; i++) {
scanf("%llf%llf%llf", &a, &b, &c);
printf("Case #%d: ", i);
printf(a+b>c?"true\n":"false\n");
}
return 0;
}
附上所有数值类型:https://blog.csdn.net/xuexiacm/article/details/8122267