Created
          December 2, 2013 00:59 
        
      - 
      
- 
        Save pepet96/7743231 to your computer and use it in GitHub Desktop. 
    Transversing Grid
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | mport java.util.Scanner; | |
| public class TraversingGrid { | |
| public static void main (String [] args) { | |
| Scanner input = new Scanner(System.in); | |
| String[] output = new String[input.nextInt()]; | |
| for (int i = 0; i < output.length; i++) { | |
| int n = input.nextInt(); | |
| int m = input.nextInt(); | |
| if (n > m) { | |
| if (m % 2 == 0) | |
| output[i] = "U"; | |
| else | |
| output[i] = "D"; | |
| } | |
| else { | |
| if (n % 2 == 0) | |
| output[i] = "L"; | |
| else | |
| output[i] = "R"; | |
| } | |
| } | |
| for (int i = 0; i < output.length; i++) | |
| System.out.println(output[i]); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment