A1065 A+B and C (64bit)

注意赋值以后才能判断是否溢出

#include <stdio.h>
typedef long long LL;

int main()
{
	LL A,B,C;
	LL sum;
	int T;
	scanf("%d",&T);
	for(int i=1;i<=T;i++){			
		scanf("%lld%lld%lld",&A,&B,&C);
		sum = A+B;
		printf("Case #%d: ",i);
		if(A>0&&B>0&&sum<=0)printf("true\n");
		else if(A<0&&B<0&&sum>=0)printf("false\n");
		else{
			if(sum>C)printf("true\n");
			else printf("false\n");
		}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43108373/article/details/84205860