Advertisement
knyazer

Untitled

Oct 15th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package com.school;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner in = new Scanner(System.in);
  9.  
  10.         int arr[] = new int[30];
  11.         int count = 1, max = 0;
  12.  
  13.         for (int i = 0; i < 30; i++) arr[i] = in.nextInt();
  14.  
  15.         for (int i = 0; i < 29; i++) {
  16.             if (arr[i] == arr[i + 1]) count += 1; // Если подряд идущие элементы совпадают - то увеличиваем счетчик
  17.             else count = 1; // Иначе сбрасываем
  18.  
  19.             if (count > max) max = count; // Находим максимальное значение счетчика
  20.         }
  21.  
  22.         System.out.println(max);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement