OneCompiler

H shape in 2 d matrics

136

import java.util.*;

public class Main {
public static void main(String[] args) {
int a[][]={{1,2,3},{4,5,6},{7,8,9}};
for(int i=0;i<a.length;i++){
for(int j=0;j<a.length;j++){

    }
  }
  for(int i=0;i<a.length;i++){
    for(int j=0;j<a.length;j++){
      if(i==j){
        System.out.print(a[i][j]+" ");
      }else if(j==0){
        System.out.print(a[i][j]+" ");
      }else if(j==2){
        System.out.print(a[i][j]+" ");
      }else{
        System.out.print("  ");
      }
    }
    System.out.println();
  }

}
}