iLLcheff

ThreeGroupsAlpha44Core

Nov 15th, 2022
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ThreeGroups {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String[] input = scanner.nextLine().split(" ");
  7.         int[] numbers = new int[input.length];
  8.         StringBuilder sbZero = new StringBuilder();
  9.         StringBuilder sbOne = new StringBuilder();
  10.         StringBuilder sbTwo = new StringBuilder();
  11.         for (int i = 0; i < input.length; i++) {
  12.             numbers[i] = Integer.parseInt(input[i]);
  13.             if (numbers[i] % 3 == 0) {
  14.                 sbZero.append(numbers[i]).append(" ");
  15.             }
  16.             if (numbers[i] % 3 == 1) {
  17.                 sbOne.append(numbers[i]).append(" ");
  18.             }
  19.             if (numbers[i] % 3 == 2) {
  20.                 sbTwo.append(numbers[i]).append(" ");
  21.             }
  22.         }
  23.         System.out.println(sbZero);
  24.         System.out.println(sbOne);
  25.         System.out.println(sbTwo);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment