package com.javarush.task.task07.task0713; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; /* Играем в Jолушку */ public class Solution { public static void main(String[] args) throws Exception { //напишите тут ваш код BufferedReader num_1 = new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer> list = new ArrayList<>(20); ArrayList<Integer> list_ch = new ArrayList<>(); ArrayList<Integer> list_nch = new ArrayList<>(); ArrayList<Integer> other = new ArrayList<>(); for (int i = 0; i < 20; i++){ list.add(Integer.parseInt(num_1.readLine())); } for (int i = 0; i < list.size(); i++){ if (list.get(i) % 3 == 0){ list_nch.add(list.get(i)); }else if (list.get(i) % 2 == 0){ list_ch.add(list.get(i)); }else if (list.get(i) % 2 != 0 && list.get(i) % 3 != 0){ other.add(list.get(i)); }if (list.get(i) % 2 == 0 && list.get(i) % 3 == 0){ list_nch.add(list.get(i)); list_ch.add(list.get(i)); } } printList(list_nch); System.out.println(); printList(list_ch); System.out.println(); printList(other); } public static void printList(ArrayList<Integer> list) { //напишите тут ваш код for (int i = 0; i < list.size(); i ++) System.out.println(list.get(i)); } } я его уже и так крутил и так крутил, вечно условия не проходит и постоянно разные. то второе и третье , то только четвертое.