Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Contar {
- public static void main(String[] args) {
- int max = 0;
- int contagem = 0;
- int numero = 0;
- Scanner input = new Scanner(System.in);
- int r=input.nextInt();
- int c=input.nextInt();
- // System.out.println(r + " " + c);
- char[][] matriz = new char[r][c];
- for(int i=0; i<r; i++) {
- String line = input.nextLine();
- for(int j=0; j<c; j++) {
- matriz[i][j] = line.charAt(j);
- }
- }
- //VERTICAL
- for (int i = 0; i < r; i++) {
- numero = 0;
- for(int j = 0; j < c; j++) {
- while (matriz[i][j] == '#') {
- numero++;
- }
- if(numero >= max) {
- max = numero;
- contagem++;
- }
- }
- }
- //HORIZONTAL
- for (int i = 0; i < c; i++) {
- numero = 0;
- for(int j = 0; j < r; j++) {
- while (matriz[i][j] == '#') {
- numero++;
- }
- if(numero >= max) {
- max = numero;
- contagem++;
- }
- }
- }
- System.out.println(max + " " + contagem);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement