Π§Π΅ΡΠ΅Π· debug ΠΏΠΎΠ»Π½ΠΎΡΡΡΡ ΠΏΡΠΎΡΠΌΠ°ΡΡΠΈΠ²Π°Π» ΠΊΠΎΠ΄ ΠΈ Π·Π°ΠΌΠ΅ΡΠΈΠ», ΡΡΠΎ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡ ΠΏΡΠΎΠΏΡΡΠΊΠ°Π΅Ρ Π²ΡΠΎΡΠΎΠΉ ΡΠΈΠΊΠ» ΠΈ ΡΡΠ°Π·Ρ ΠΏΠ΅ΡΠ΅Ρ
ΠΎΠ΄ΠΈΡ ΠΊ
System.out.println(Collections.max(ints2));
ΠΠ°ΠΊ Π±Ρ Ρ Π½Π΅ ΠΊΡΡΡΠΈΠ» Π²ΡΠΎΡΠΎΠΉ ΡΠΈΠΊΠ» for (), ΠΊ ΡΡΠΏΠ΅Ρ
Ρ ΡΡΠΎ Π½Π΅ ΠΏΡΠΈΠ²Π΅Π»ΠΎ...
ΠΠΎΠ΄ΡΠΊΠ°ΠΆΠΈΡΠ΅, ΡΠΌΠ½ΡΠ΅ Π»ΡΠ΄ΠΈpackage com.javarush.task.task08.task0812;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/*
CΠ°ΠΌΠ°Ρ Π΄Π»ΠΈΠ½Π½Π°Ρ ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎΡΡΡ
*/
public class Solution {
public static void main(String[] args) {
ArrayList<Integer> ints = new ArrayList<>(10);
ArrayList<Integer> ints2 = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
ints.add(scanner.nextInt());
ints2.add(0);
}
int b = 0;
int index = 0;
for (int i = ints.size() - 2; i <= 0; i--) {
if (ints.get(i) == ints.get(i + 1)) {
ints2.set(index, b++);
}
else {
b = 0;
index++;
}
}
System.out.println(Collections.max(ints2));
}
}