Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Contar {
  5. public static void main(String[] args) {
  6.         int max = 0;
  7.         int contagem = 0;
  8.         int numero = 0;
  9.         Scanner input = new Scanner(System.in);
  10.         int r=input.nextInt();
  11.         int c=input.nextInt();
  12.         // System.out.println(r + " " + c);
  13.         char[][] matriz =  new char[r][c];
  14.         for(int i=0; i<r; i++) {
  15.                 String line = input.nextLine();
  16.                 for(int j=0; j<c; j++) {
  17.                         matriz[i][j] = line.charAt(j);
  18.                 }
  19.         }
  20.  
  21.         //VERTICAL
  22.         for (int i = 0; i < r; i++) {
  23.                 numero = 0;
  24.                 for(int j = 0; j < c; j++) {
  25.                         while (matriz[i][j] == '#') {
  26.                                 numero++;
  27.                         }
  28.                         if(numero >= max) {
  29.                                 max = numero;
  30.                                 contagem++;
  31.                         }
  32.                 }
  33.         }
  34.  
  35.  
  36.         //HORIZONTAL
  37.         for (int i = 0; i < c; i++) {
  38.                 numero = 0;
  39.                 for(int j = 0; j < r; j++) {
  40.                         while (matriz[i][j] == '#') {
  41.                                 numero++;
  42.                         }
  43.                         if(numero >= max) {
  44.                                 max = numero;
  45.                                 contagem++;
  46.                         }
  47.                 }
  48.         }
  49.  
  50.         System.out.println(max + " " + contagem);
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement