Advertisement
bizzcuit

Паркиране

Jan 31st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7. int n = in.nextInt();
  8. int m = in.nextInt();
  9. in.nextLine();
  10. int zeroX = 0;
  11. int oneX = 0;
  12. int twoX = 0;
  13. int threeX = 0;
  14. int fourX = 0;
  15. String firstLine = in.nextLine();
  16.  
  17. for (int i = 0; i < n - 1; i++) {
  18. String secondLine = in.nextLine();
  19. for (int j = 0; j < m - 1; j++) {
  20. String cell = "" + firstLine.charAt(j) + firstLine.charAt(j + 1) + secondLine.charAt(j) + secondLine.charAt(j + 1);
  21. if (cell.contains("#")){
  22. continue;
  23. }
  24. int count = cell.length() - cell.replace("X", "").length();
  25.  
  26. switch (count){
  27. case 0: zeroX++; break;
  28. case 1: oneX++; break;
  29. case 2: twoX++; break;
  30. case 3: threeX++; break;
  31. case 4: fourX++; break;
  32. }
  33. }
  34. firstLine = secondLine;
  35. }
  36.  
  37. System.out.println(zeroX);
  38. System.out.println(oneX);
  39. System.out.println(twoX);
  40. System.out.println(threeX);
  41. System.out.println(fourX);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement