博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT甲级——A1065 A+B and C (64bit)
阅读量:4541 次
发布时间:2019-06-08

本文共 1270 字,大约阅读时间需要 4 分钟。

Given three integers A, B and C in [−], you are supposed to tell whether A+B>C.

Input Specification:

The first line of the input gives the positive number of test cases, T (≤). Then T test cases follow, each consists of a single line containing three integers A, B and C, separated by single spaces.

Output Specification:

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

Sample Input:

31 2 32 3 49223372036854775807 -9223372036854775808 0

Sample Output:

Case #1: falseCase #2: trueCase #3: false
1 #include 
2 using namespace std; 3 long long N, A, B, C, sum; 4 int main() 5 { 6 cin >> N; 7 for (int i = 1; i <= N; ++i) 8 { 9 cin >> A >> B >> C;10 sum = A + B;11 if (A > 0 && B > 0 && sum < 0)//正溢出12 cout << "Case #" << i << ": " << "true" << endl;13 else if (A < 0 && B < 0 && sum >= 0)//负溢出14 cout << "Case #" << i << ": " << "false" << endl;15 else if(sum>C)16 cout << "Case #" << i << ": " << "true" << endl;17 else18 cout << "Case #" << i << ": " << "false" << endl;19 }20 return 0;21 }

 

 

转载于:https://www.cnblogs.com/zzw1024/p/11295948.html

你可能感兴趣的文章
[Noip2016] 愤怒的小鸟
查看>>
JAVA wait()和notifyAll()实现线程间通讯
查看>>
python全栈脱产第11天------装饰器
查看>>
[总结]数据结构(板子)
查看>>
C# 笔记
查看>>
[转]人人店短信插件开发
查看>>
[转]c# System.IO.Ports SerialPort Class
查看>>
14. 最长公共前缀
查看>>
Redis文档
查看>>
项目重构
查看>>
(笔试题)和一半的组合数
查看>>
leetcode--Algorithm--Array_Part 1 Easy- 566 Reshape the Matrix
查看>>
AC自动机算法详解 (转载)
查看>>
python3-day5(模块)
查看>>
Linux配置JDK
查看>>
qt 读取xml文件
查看>>
python3之正则表达式
查看>>
Visual Studio提示“无法启动IIS Express Web服务器”的解决方法
查看>>
Java 时间总结
查看>>
jQuery EasyUI 拖放 – 基本的拖动和放置
查看>>