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 X is the case number (starting from 1).

Sample Input:

3
1 2 3
2 3 4
9223372036854775807 -9223372036854775808 0

Sample Output:

Case #1: false
Case #2: true
Case #3: false
这个上面有2个Case是不能过的,在g++,但是在clang++可以过。
#include <iostream>
using namespace std;
int main(){
/**
依据算法笔记,以及其他人的博客,可知
可以进行溢出判断
1.即两个正数和为负数,溢出,比结果大
2.两个负数和为正数,溢出,比结果肯定小
3.一正一负直接比较
long long长度[-2**63,2**63)
*/
int T;long long a,b,c;
cin>>T;bool flag;//flag为true是true,false为false
for(int i=;i<T;i++){
cin>>a>>b>>c;
if(a>&&b>&&(a+b)<) flag=true;
else if(a<&&b<&&(a+b)>=) flag=false;
else{
if(a+b>c) flag=true;
else flag=false;
}
if(flag) cout<<"Case #"<<(i+)<<": true"<<endl;
else cout<<"Case #"<<(i+)<<": false"<<endl;
}
system("pause");
return ;
}

要想在g++过这个Case 可以使用用res存储的方式。至今不知道为啥不能直接比较,在g++上
#include <iostream>
using namespace std;
int main(){
/**
依据算法笔记,以及其他人的博客,可知
可以进行溢出判断
1.即两个正数和为负数,溢出,比结果大
2.两个负数和为正数,溢出,比结果肯定小
3.一正一负直接比较
long long长度[-2**63,2**63)
*/
int T;long long a,b,c,res;
cin>>T;bool flag;//flag为true是true,false为false
for(int i=;i<T;i++){
cin>>a>>b>>c;
res=a+b;
if(a>&&b>&&res<) flag=true;
else if(a<&&b<&&res>=) flag=false;
else{
if(res>c) flag=true;
else flag=false;
}
if(flag) cout<<"Case #"<<(i+)<<": true"<<endl;
else cout<<"Case #"<<(i+)<<": false"<<endl;
}
system("pause");
return ;
}

最新文章

  1. Hui之Hui.js 官方文档
  2. 【小白的CFD之旅】12 敲门实例【续2】
  3. 修改centos启动项
  4. Android Paint和Color类绘画实例
  5. Windows下Python工具pip的安装
  6. C#出题库项目的总结(1)
  7. TBluetoothLE
  8. 通过软引用和弱引用提升JVM内存使用性能的方法(面试时找机会说出,一定能提升成功率)
  9. 河北大学python选修课00次作业
  10. js中style,currentStyle和getComputedStyle的区别以及获取css样式操作方法
  11. Sqlserver脚本创建登录名密码
  12. OpenCV3 for python3 学习笔记1
  13. javascript 新建实例对象
  14. Synchronzied(内置锁)
  15. 课程一(Neural Networks and Deep Learning),第一周(Introduction to Deep Learning)—— 0、学习目标
  16. 自己动手写Impala UDF
  17. [Forward]Sweeping the IDisposable minefield
  18. day 56 linux的安装python3 ,虚拟环境,mysql ,redis
  19. go 函数举例练习
  20. Android 如何修改默认输入法

热门文章

  1. ENGINE =MyISAM DEFAULT CHARACTER SET latin1 COLLATE latin1_general_cs AUTO_INCREMENT=0; 什么意思
  2. 看完你也想编写自己的 react 插件
  3. List of Mozilla-Based Applications
  4. 网络协议之TCP/IP协议
  5. C++ 左值与右值
  6. WPF中的WndProc
  7. NumericStream &amp;&amp; Stream综合练习
  8. Redis存储对象序列化和反序列化
  9. Matlab——矩阵运算 矩阵基本变换操作
  10. 获取当前页面的title