knyazer

Untitled

Apr 21st, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 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.  
  8. int a = in.nextInt(), b = in.nextInt();
  9. boolean arr[][] = new boolean[a][b];
  10.  
  11. int counter = 0;
  12.  
  13. for (int i = 0; i < a; i++) {
  14. String line = in.next();
  15. for (int j = 0; j < b; j++) {
  16. arr[i][j] = (line.charAt(j) == ('#'));
  17. if (arr[i][j]) {
  18. if ((i == 0 || !arr[i - 1][j]) && (j == 0 || !arr[i][j - 1])) {
  19. counter += 1;
  20. }
  21. }
  22. }
  23. }
  24.  
  25. System.out.println(counter);
  26. }
  27. }
Add Comment
Please, Sign In to add comment