OneCompiler

How to printt left diagonal element of the 2 d matrics

156
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner input=new Scanner(System.in);
      int a=input.nextInt();
      int b=input.nextInt();
      int c[][]=new int [a][b];
      for(int i=0;i<a;i++)
            {
                for(int j=0;j<b;j++){
              c[i][j]=input.nextInt();  
                }
              
            }
            for(int i=0;i<a;i++){
              for(int j=b-1;j>=0;j--){
                if((i+j)==(a-1)){
                  System.out.print(c[i][j]);
                }
                
              }
              System.out.println();
            }
    }
}