Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int n = in.nextInt();
- int m = in.nextInt();
- in.nextLine();
- int zeroX = 0;
- int oneX = 0;
- int twoX = 0;
- int threeX = 0;
- int fourX = 0;
- String firstLine = in.nextLine();
- for (int i = 0; i < n - 1; i++) {
- String secondLine = in.nextLine();
- for (int j = 0; j < m - 1; j++) {
- String cell = "" + firstLine.charAt(j) + firstLine.charAt(j + 1) + secondLine.charAt(j) + secondLine.charAt(j + 1);
- if (cell.contains("#")){
- continue;
- }
- int count = cell.length() - cell.replace("X", "").length();
- switch (count){
- case 0: zeroX++; break;
- case 1: oneX++; break;
- case 2: twoX++; break;
- case 3: threeX++; break;
- case 4: fourX++; break;
- }
- }
- firstLine = secondLine;
- }
- System.out.println(zeroX);
- System.out.println(oneX);
- System.out.println(twoX);
- System.out.println(threeX);
- System.out.println(fourX);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement