C++ Pat B 1011. A+b and C (15/15)

Source: Internet
Author: User
Tags int size

/*1011. A+b and C (15) 3 integers a, B, and C in a given interval [ -2^31, 2^31], determine if A+B is greater than C. Input format: Enter the 1th line to give a 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 format: 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 from 1).    Input Sample: 41 2 32 3 42147483647 0 21474836460-2147483648-2147483647 Output Sample: Case #1: False cases #2: True case #3: True Case #4: false*//* Note: To consider the range of the base data type int [ -2^31, 2^31]-may be at risk of overflow double [ -10^308, 10^308]-and range security */#include <iostream> #include <string.h>using namespace Std;int main () {int size    ;    scanf ("%d", &size);    Double a,b,c;    BOOL *results = new bool[size+1];        for (int i=1;i<=size;i++) {cin>>a>>b>>c;        Results[i] = false;        if (a+b>c) {results[i] = true; }} for (int i=1;i<=size;i++) {printf ("Case #%d:%s\n", I, results[i]==true? ")    True ":" false "); } return 0;} 

  

C++ Pat B 1011. A+b and C (15/15)

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.