UVA online Judge Solution -11172 - Relational Operator by C, C++ - Code Solve 01

Latest

Wednesday, May 2, 2018

UVA online Judge Solution -11172 - Relational Operator by C, C++



URI Online Judge | 11172

Relational Operator 


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 

10 20
20 10 
10 10

Sample Output

>
=

Solution in C language:
#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    scanf("%d",&num);

    int arr[num][2];
    int i;
    for(i=0; i<num; i++)
    {
        scanf("%d %d",&arr[i][0],&arr[i][1]);
    }

    for(i=0; i<num; i++)
    {
        int a,b;
        a=arr[i][0];
        b=arr[i][1];
        if(a==b)
            printf("=\n");
        else if(a<b)
            printf("<\n");
        else
            printf(">\n");
        }
    return 0;
}

No comments:

Post a Comment