import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc1 = new Scanner(System.in);
int a = sc1.nextInt();
int b = sc1.nextInt();
int c = sc1.nextInt();
int d = sc1.nextInt();
if (a>=b && a>=c)
{
if (b>=c)
{
System.out.println(c + " " + b + " " + a);
}
else
{
System.out.println(b + " " + c + " " + a);
}
}
if (b>=a && b>=c)
{
if (c>=a)
{
System.out.println(a + " " + c + " " + b);
}
else
{
System.out.println(c + " " + a + " " + b);
}
}
if (c>=a && c>=b)
{
if (a>=b)
{
System.out.println(b + " " + a + " " + c);
}
else
{
System.out.println(a + " " + b + " " + c);
}
}
}
}
Help!!!
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
29 November 2019, 15:05
When asking for help, make sure that you attach the solution. A lot of these tasks have specific requirements and just copy+pasting code means nothing without the requirements. I do know this tasks however.
There are 2 errors with your code:
#1 the requirements say to enter only numbers, but you have an extra line:
int d = sc1.nextInt();
remove this.
#2 You have three main if statements that will all be checked against the inputs. This works fine when you enter 3 numbers that are not equal; however, when you enter 3 identical numbers, all three the if statements in this code will be true and you will get 3 lines of output. You will need to fix this.
0