UVALive4716 Relational Operators【水题】

The relational operators in C programming language are shown in the table below. Of course the last two are also known as equality operators.

UVALive4716 Relational Operators【水题】_第1张图片

  These operators compare the value of the two operands it is working on (The value on its left and the value on its right) and returns true or false (one or zero). For example value of 2 > 3 is interpreted as “false” (As 2 is actually less than 3), value of 3 != 4 is interpreted as true and value of 3 >= 3 is also interpreted as true. You have to find out this interpretation using a program.

Input

The input file contains around 12000 line of input. Each line contains two integers a and b separated byan operator ‘>’, ‘>=’, ‘<’, ‘<=’, ‘==’ or ‘!=’. Input is terminated by a line which contains an ‘E’ insteadof the operators. Note that there is also a space between any operator and operand. You can assume(− 10000 ≤ a, b ≤ 10000).

Output

For each line of input produce one line of output. This line contains the serial of output followed bya string ‘true’ or ‘false’ (without the quotes) which denotes how the expression is interpreted in Clanguage. Look at the output for sample input for details.

Sample Input

3 != 3

4 < 4

4 <= 5

3 E 3

Sample Output

Case 1: false

Case 2: false

Case 3: true


Regionals 2009 >> Asia - Phuket


问题链接:UVALive4716 Relational Operators

问题简述:(略)

问题分析

  大水题,不用解释。

程序说明:(略)

题记:(略)

参考链接:(略)


AC的C++语言程序如下:

/* UVALive4716 Relational Operators */

#include 

using namespace std;

int main()
{
    int caseno=0, a, b;
    string op;

    while(cin >> a >> op >> b && op != "E") {
        bool ans = ((op == ">" && a > b)
                    || (op == ">=" && a >= b)
                    || (op == "<" && a < b)
                    || (op == "<=" && a <= b)
                    || (op == "==" && a == b)
                    || (op == "!=" && a != b));

        printf("Case %d: %s\n", ++caseno, ans ? "true" : "false");
    }

    return 0;
}





你可能感兴趣的:(#,ICPC-备用二,#,ICPC-水题题解三,#,ICPC-UVALive)