编程语言
首页 > 编程语言> > 【通过PAT复习C++与数据结构】PAT-A 1065. A+B and C (64bit) (20)

【通过PAT复习C++与数据结构】PAT-A 1065. A+B and C (64bit) (20)

作者:互联网

题目描述

题目描述
Given three integers A, B and C in [-263, 263), you are supposed to tell whether A+B > C.

输入描述:
The first line of the input gives the positive number of test cases, T (<=1000). Then T test cases follow, each consists of a single line containing three integers A, B and C, separated by single spaces.

输出描述:
For each test case, output in one line “Case #X: true” if A+B>C, or “Case #X: false” otherwise, where X is the case number (starting from 1).

输入例子:
3
1 2 3
2 3 4
9223372036854775807 -9223372036854775808 0

输出例子:
Case #1: false
Case #2: true
Case #3: false

解题思路

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int t;
	cin>>t;
	_int64 a,b,c;
	for(int i=1;i<=t;++i){
		cin>>a>>b>>c;
		if(a+b>c){
			if(i!=t)cout<<"Case #"<<i<<": true"<<endl;
			else cout<<"Case #"<<i<<": true";
		}
		else{
			if(i!=t)cout<<"Case #"<<i<<": false"<<endl;
			else cout<<"Case #"<<i<<": false";
		}
	}
	return 0;
}

标签:Case,PAT,int,double,64bit,1065,long,false,include
来源: https://blog.csdn.net/qq_41010971/article/details/94867037