package com.codegym.task.task04.task0441;
/*
Somehow average
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(in.readLine());
int b = Integer.parseInt(in.readLine());
int c = Integer.parseInt(in.readLine());
if(a >= b && a <= c){
System.out.println(a);
}
else if(a > b && b > c && c < a){
System.out.println(b);
}
if(b >= a && b <= c){
System.out.println(b);
}
else if(a > b && b < c && c != a){
System.out.println(c);
}
else if(b > a && b > c){
System.out.println(b);
}
if(c >= a && c <= b){
System.out.println(c);
}
else if(c > a && c > b){
System.out.println(c);
}
if(a == b || a == c){
System.out.println(a);
}
else if(b == a || b == c){
System.out.println(b);
}
else if(c == a || c == b){
System.out.println(c);
}
else {
System.out.println(a);
}
}
}
NOBODY
Level 5
help please
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Patryk
7 May 2020, 12:26
please my code :
if(isEqual(first, second) == 0) {
//first, second
System.out.println(first);
} else if(isEqual(second, third) == 0) {
//second , third
System.out.println(second);
} else if( ( (isEqual(first,second) > 0) && (isEqual(first,third) < 0) ) || ( (isEqual(first,third) > 0) && (isEqual(first,second) < 0) ) ) {
System.out.println(first);
} else if( ( (isEqual(second,first) > 0) && (isEqual(second,third) < 0) ) || ( (isEqual(second,third) > 0) && (isEqual(second,first) < 0) ) ) {
System.out.println(second);
} else if( ( (isEqual(third,first) > 0) && (isEqual(third,second) < 0) ) || ( (isEqual(third,second) > 0) && (isEqual(third,first) < 0) ) ) {
System.out.println(third);
} else {
System.out.println(third);
}
}
public static int isEqual(int first, int second) {
if(first > second) {
return 1; //large
} else if (first < second) {
return -1; //small
} else {
return 0; // equals
}
}
+1