• + 1 comment

    For the Java people wondering how to accept the String matrix, here is a way,

    ` char c[][]=new char[n][n]; String s[]=new String[n];

         for(int i=0;i<n;i++){
             s[i]=sc.next();
                         }
    
         for(int i=0;i<n;i++){ 
             int k=0;
    
             for(int j=0;j<n;j++){
    
               c[i][j]=s[i].charAt(k);
    
               k++;
                             }}