PAT/B/1011
#include <iostream>
using namespace std;
int main()
{
int t;
long long int a,b,c;
cin>>t;
for(int i=1;i<=t;++i)
{
cin>>a>>b>>c;
a=a-c;
b=b*(-1);
cout<<"Case #"<<i<<": ";
if(a>b) cout<<"true";
else cout<<"false";
if(i!=t) cout<<endl;
}
return 0;
}
int 是刚好是题目的范围,所以数相加的话要用long long int,就可以直接操作了,其他也没什么东西了
liuchuo大神:
#include <iostream>
using namespace std;
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
long long int a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
printf("Case #%d: %s\n", i + 1, a + b > c ? "true" : "false");
}
return 0;
}