Thursday, 6 August 2015

Uva - 11172 - Relational Operator UVa Problem Solution Using C++.

                                11172 - Relational Operator

Some op erators checks ab out the relationship b etween two values and these op erators are called relational op erators. Given two numerical values your job is just to find out the relationship b etween 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
<

>
=
TAG: C++ , Algorithm , UVa Problem , Easy Solution .


Problem Link: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2113

Solution:

#include<bits/stdc++.h>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main(){

    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int a,b;cin >> a >> b;
        if(a > b)cout << ">" << endl;
        if(a < b)cout << "<" << endl;
        if(a == b)cout << "==" << endl;
    }
    return 0;
}

1 comment:

  1. how to do the same probelm using while and if else loops

    ReplyDelete