Advertisement
roronoa

correction assessment

Apr 25th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4.  
  5. class Solution {
  6.  
  7.     public static void main(String args[]) {
  8.         Scanner in = new Scanner(System.in);
  9.         int n = in.nextInt();
  10.         if (in.hasNextLine()) {
  11.             in.nextLine();
  12.         }
  13.         String k = in.nextLine();
  14.         String kChiff="";
  15.         int bonneRep = 0;
  16.         for(int i = 0; i < k.length(); i++)
  17.         {
  18.             kChiff += k.charAt(i)-'A';
  19.         }
  20.         for (int i = 0; i < n; i++)
  21.         {
  22.             String a = in.nextLine();
  23.             if(a.charAt(kChiff.charAt(i)-'0') == 'X' && countXInString(a,'X') == 1)
  24.                 bonneRep++;
  25.         }
  26.        
  27.  
  28.         System.out.println(bonneRep*100/n);
  29.     }
  30.     public static int countXInString(String s, char x)
  31.     {
  32.         int res = 0;
  33.         for(int i = 0; i < s.length(); i++)
  34.         {
  35.             if(s.charAt(i) == x)
  36.                 res++;
  37.         }
  38.         return res;
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement