Advertisement
roronoa

ebauche code correcteur d'erreur

May 1st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. //public class soluce..
  2. public static Map<String, Integer> hash = new HashMap<>();
  3. public static void main(String[] args)
  4.     {
  5.         //connect();
  6.         Scanner in = new Scanner(System.in);
  7.         hash.put("c",in.nextInt());
  8.         hash.put("b",in.nextInt());
  9.         hash.put("bc",in.nextInt());
  10.         hash.put("a",in.nextInt());
  11.         hash.put("ac",in.nextInt());
  12.         hash.put("ab",in.nextInt());
  13.         hash.put("abc",in.nextInt());
  14.         while(getSumOfX("a")%2 != 0 || getSumOfX("b")%2 != 0 || getSumOfX("c")%2 != 0)
  15.         {
  16.             for(String s : hash.keySet())
  17.             {
  18.                 hash.put(s, (hash.get(s)+ 1)%2);
  19.             }
  20.             if(getSumOfX("a")%2 == 0 && getSumOfX("b")%2 == 0 && getSumOfX("c")%2 == 0)
  21.                 break;
  22.         }
  23.         String res ="";
  24.         for(String s : hash.keySet())
  25.         {
  26.             res += hash.get(s) + " ";
  27.         }
  28.         System.out.println(res.trim());
  29.     }
  30.     public static int getSumOfX(String x)
  31.     {
  32.         int sum = 0;
  33.         for(String s : hash.keySet())
  34.         {
  35.             if(s.indexOf(x) != -1)
  36.                 sum += hash.get(s);
  37.         }
  38.         return 0;
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement