Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- class Solution {
- public static void main(String args[])
- {
- Scanner in = new Scanner(System.in);
- char mat[][] = new char[9][9];
- char res[][] = new char[9][9];
- int subSquare=0; //max=8;
- for (int i = 0; i < 9; i++) {
- for (int j = 0; j < 9; j++) {
- String x = in.nextLine();
- mat[i]=x.toCharArray();
- }
- }
- int l = 0, c = 0;
- int x = 0;
- for(int i = 0; i < 9; i++)
- {
- for(int j = 0; j < 9; j++)
- {
- //col = 3*i
- res[i][j]=mat[l][c];
- c++;
- if(c%3==0)
- {
- c = x;
- l++;
- }
- if(l%3 == 0)
- {
- l = 0;
- c+=3;
- }
- }
- }
- for(int i = 0; i < 9; i++)
- {
- for(int j = 0; j < 9; j++)
- {
- System.out.print(res[i][j]);
- if(j==8)
- System.out.println();
- else
- System.out.print(" ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement