The checker says my numbers aren't in descending order even though they are. What's going on?
Code below:
public class Solution {
public static int maxi(int f, int s) {
if (f>s) return f;
else return s;
}
public static int mini(int f, int s) {
if (f>s) return s;
else return f;
}
public static void main(String[] args) throws Exception {
//write your code here
int a = Integer.parseInt((new BufferedReader(new InputStreamReader (System.in ))).readLine() );
int b = Integer.parseInt((new BufferedReader(new InputStreamReader (System.in ))).readLine() );
int c = Integer.parseInt((new BufferedReader(new InputStreamReader (System.in ))).readLine() );
if (a>b && a>c) System.out.println(a+" "+maxi(b, c)+" "+mini(b, c) );
else if (b>c && b>a) System.out.println(b+" "+maxi(a, c)+" "+mini(a, c));
else System.out.println(c+" "+maxi(a, b)+" "+mini(b, a)) ;
}
}
Numbers not in descending order
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
horst
1 January 2020, 11:17
The first thing that comes to mind - although I can't remember if this was part of the scenario:
What does your code do when two numbers are identical?
Just looking at the printing-conditions (last three lines), if a equals b, then it will always print the line that starts with c, right?
0