A+b and C (15) time limit MS Memory limit 32768 KB code length limit of KB Judging program standard (from small)
Title Description
The 3 integers a, B, and C in a given interval [2 of 31, 2 of 31], determine if A+B is greater than C.
Input Description:
Enter line 1th to give the positive integer t (<=10), which is the number of test cases. The T-group test cases are then given, one row for each group, and a, B, and C in order. The integers are separated by a space.
Output Description:
For each set of test cases, output "case #X: True" in one row if a+b>c, otherwise the output is "case #X: false", where X is the number of the test cases (starting at 1).
Input Example:
4
1 2 3
2 3 4
2147483647 0 2147483646
0-2147483648-2147483647
Output Example:
case #1: false
Case #2: True
Case #3: True
Case #4: false
This problem is mainly not directly to compare the size of a+b and C, need to divide the situation, the indirect to discuss
below is the code of AC
#include <iostream> #define LINT Long Long intusing namespace Std;int main () {LINT n;cin>>n; LINT K=1;while (n--) {LINT a,b,c;cin>>a>>b>>c;if ((a>=0&&b<=0) | | (a<=0&&b>=0)) {if (a+b>c) cout<< "Case #" <<k<< ": True" <<endl;elsecout<< "Case #" <<k<< " : false "<<endl;k++;} else if (a>0&&b>0) {if (c<=a| | C<=B) cout<< "Case #" <<k<< ": True" <<endl;else{if (c-a>=b) cout<< ' Case # ' <<k << ": false" <<endl;elsecout<< "Case #" <<k<< ": true" <<ENDL;} k++;} else if (a<0&&b<0) {if (c>=a| | C>=B) cout<< "Case #" <<k<< ": false" <<endl;else{if (c-a>=b) cout<< ' Case # ' << k<< ": false" <<endl;elsecout<< "Case #" <<k<< ": true" <<ENDL;} k++;}}}
Pat--a+b and C (study type data storage)