1011. A+B和C (15)
来源:互联网 发布:js encode 编辑:程序博客网 时间:2024/06/06 12:52
时间限制
50 ms
内存限制
32000 kB
代码长度限制
8000 B
判题程序
Standard
作者
HOU, Qiming
给定区间[-231, 231]内的3个整数A、B和C,请判断A+B是否大于C。
输入格式:
输入第1行给出正整数T(<=10),是测试用例的个数。随后给出T组测试用例,每组占一行,顺序给出A、B和C。整数间以空格分隔。
输出格式:
对每组测试用例,在一行中输出“Case #X: true”如果A+B>C,否则输出“Case #X: false”,其中X是测试用例的编号(从1开始)。
输入样例:
4
1 2 3
2 3 4
2147483647 0 2147483646
0 -2147483648 -2147483647
输出样例:
Case #1: false
Case #2: true
Case #3: true
Case #4: false
//部分错误,未找到原因#include<iostream>#include<string>using namespace std;int main(){ int T,a,b,c; cin>>T; for(int i=0;i<T;i++) { cin>>a>>b>>c; char *d=(char*)a; int e=(long)&d[b]; if (e>c) cout<<"Case #"<<i+1<<": true"<<endl; else cout<<"Case #"<<i+1<<": false"<<endl; } return 0;}//想的太复杂了,以为需要很麻烦的大数相加直接double就可以了#include<iostream>#include<string>using namespace std;int main(){ double T,a,b,c; cin>>T; for(int i=0;i<T;i++) { cin>>a>>b>>c; double e =a+b; if (e>c) cout<<"Case #"<<i+1<<": true"<<endl; else cout<<"Case #"<<i+1<<": false"<<endl; } return 0;}
0 0
- PAT 1011. A+B和C (15)
- 1011. A+B和C (15)
- PAT - 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- 1011. A+B和C (15)
- freecodecamp advance algorithm scripting
- 简单的爬取新浪新闻标题与链接
- python和lua的socket实例
- android 瀑布流布局 + 自由拖拽
- 利用AXIS2返回JSON
- 1011. A+B和C (15)
- 程序员的思考
- LeetCode 61. Rotate List
- 字符集与编码二之编号 vs 编码
- reactNative react.children.only expected to receive a single react element child.问题
- OpenGLES的简单应用绘图,以及照相机画面变色变形渲染(六)
- centos7中安装redis
- bzoj 4006: [JLOI2015]管道连接 斯坦纳树
- 字符串扩展