Pat--a+b and C (study type data storage)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.