Print 2D array

 

Given a 2D integer array with n rows and m columns. Print the 0th row from input n times, 1st row n-1 times…..(n-1)th row will be printed 1 time.


Sample Input :
3 3
1    2    3
4    5    6
7    8    9
Sample Output :
1    2    3
1    2    3
1    2    3
4    5    6
4    5    6
7    8    9
public class solution {
	public static void print2DArray(int input[][]) {
	

        for(int i=0;i<input.length;i++)
        {
            for(int k=0;k<(input.length-i);k++)
            {
				for(int j=0;j<input[i].length;j++)
                {
					System.out.print(input[i][j]+" ");
				}
				System.out.println();
				
			}
	}
}
}

Comments

Popular posts from this blog

Minimum Length Word

Check Number Sequence

Star Pattern