Advertisement
roronoa

chiffre manquant dans chaque colonne matrice

Jun 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4.  
  5. class Solution
  6. {
  7.  
  8.     public static void main(String args[])
  9.     {
  10.         Scanner in = new Scanner(System.in);
  11.         char[][] matrix = new char[9][9];
  12.         Map<Integer, Boolean> map = new HashMap<>();
  13.        
  14.         for (int i = 0; i < 9; i++)
  15.         {
  16.             String w = in.nextLine();
  17.             for(int j = 0; j < 9; j++)
  18.                 matrix[i][j] = w.charAt(j);  
  19.         }
  20.         for(int i = 0; i < 9; i++)
  21.         {
  22.             for(int k = 1; k <= 9; k++)
  23.                 map.put(k,false);
  24.             for(int j = 0; j < 9; j++)  
  25.                 if(Character.isDigit(matrix[j][i]))
  26.                     map.put(matrix[j][i]-'0',true);
  27.             for(int x : map.keySet())
  28.                 if(map.get(x) == false)
  29.                     System.out.print(x);
  30.         }
  31.  
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement