PATTERNS - L5

PATTERNS - L5

Problem Description


Write a java program to display the following patterns

Logic Test Case 1


Input (stdin)

7


Expected Output


7 6 5 4 3 2 1 


7 6 5 4 3 2 


7 6 5 4 3 


7 6 5 4 


7 6 5 


7 6 


7

Logic Test Case 2


Input (stdin)

5


Expected Output


5 4 3 2 1 


5 4 3 2 


5 4 3 


5 4 


5




Code Area

import java.io.*;

import java.util.Scanner;

public class TestClass {

public static void main(String[] args) 

     { 

Scanner s=new Scanner(System.in);

        int rows=s.nextInt();

        for(int i=1;i<=rows;i++)

        {

          for(int j=rows;j>=i;j--)

          { 

            System.out.print(j+" ");

          }

          System.out.println();

}

     }

} 

Post a Comment

0 Comments