4月 04, 2009

【解題】Relational Operators

@
ACM Volume CXI 11172 - Relational Operators


The Problem

Some operators checks about the relationship between two values and these operators are called relational operators. Given two numerical values your job is just to find out the relationship between them that is (i) First one is greater than the second (ii) First one is less than the second or (iii) First and second one is equal.


Input

First line of the input file is an integer t (t<15) which denotes how many sets of inputs are there. Each of the next t lines contain two integers a and b (|a|,|b|<1000000001).


Output

For each line of input produce one line of output. This line contains any one of the relational operators “>”, “<” or “=”, which indicates the relation that is appropriate for the given two numbers.


Sample Input

3
10 20
20 10
10 10


Sample Output

<
>
=


解題思考

  a 小於 b 輸出 "<"、a 大於 b 輸出 ">"、a 等於 b 輸出 "="。

  我想,這題怎麼寫也不用多提了吧。


參考解答(C++)

#include <iostream>

using namespace std;

int main(void)
{
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        long a, b;
        cin >> a >> b;

        if (a < b)      { cout << "<"; }
        else if (a > b) { cout << ">"; }
        else            { cout << "="; }

        cout << endl;
    }

#ifndef ONLINE_JUDGE
    system("pause");
#endif

    return 0;
}

0 回覆:

張貼留言