Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int firstNum = Integer.parseInt(scanner.nextLine()),
- secondNum = Integer.parseInt(scanner.nextLine()),
- thirdNum = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < 3; i++) {
- if (firstNum > secondNum && firstNum > thirdNum) {
- System.out.println(firstNum);
- firstNum = Integer.MIN_VALUE;
- } else if (secondNum > firstNum && secondNum > thirdNum) {
- System.out.println(secondNum);
- secondNum = Integer.MIN_VALUE;
- } else {
- System.out.println(thirdNum);
- thirdNum = Integer.MIN_VALUE;
- }
- }
- }
- }
- Решение с масив:
- import java.util.Scanner;
- import java.util.Arrays;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int[] numbers = new int[3];
- for (int i = 0; i < 3; i++) {
- numbers[i] = Integer.parseInt(scanner.nextLine());
- }
- Arrays.sort(numbers);
- for (int i = 2; i >= 0; i--) {
- System.out.println(numbers[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement