Pages

Thursday, September 17, 2015

Relational Operator (KICTM UiTM Jasin 2015)

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

  • First one is greater than the second 
  • First one is less than the second 
  • 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
<
>
=



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
import java.lang.*;
import java.math.*;

public class Q8{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line = System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
            
      for(int x=0;x<cases;x++){
         String[] get = scan.next().split(" ");
         
         long val1 = Long.parseLong(get[0]);
         long val2 = Long.parseLong(get[1]);

         if(val1 < val2)
            System.out.println("<");
         else if(val1 > val2)
            System.out.println(">");
         else if(val1 == val2)
            System.out.println("=");
      }
   }
}

No comments:

Post a Comment