• Source
    1. import java.util.*;
    2. public class MyClass {
    3. public static void main(String args[]) {
    4. Scanner sc=new Scanner(System.in);
    5. int m=sc.nextInt();
    6. int n=sc.nextInt();
    7. int [][]a=new int[n][m];
    8. for(int i=0;i<n;i++){
    9. for(int j=0;j<m;j++){
    10. a[i][j]=sc.nextInt();
    11. if(i==0||i==n-1){
    12. System.out.print(a[i][j]+" ");
    13. }
    14. else if(i+j==n-1){
    15. for(int k=0;k<j;k++){
    16. System.out.print(" ");
    17. }
    18. System.out.print(a[i][j]+" ");
    19. }
    20. }
    21. System.out.println();
    22. }
    23.  
    24. }
    25. }