Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.school;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int arr[] = new int[30];
- int count = 1, max = 0;
- for (int i = 0; i < 30; i++) arr[i] = in.nextInt();
- for (int i = 0; i < 29; i++) {
- if (arr[i] == arr[i + 1]) count += 1; // Если подряд идущие элементы совпадают - то увеличиваем счетчик
- else count = 1; // Иначе сбрасываем
- if (count > max) max = count; // Находим максимальное значение счетчика
- }
- System.out.println(max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement