+ 4
Challenge for Coders.
Write a code to input three numbers Then display which is the second highest number. You cannot use if statement or ternary operator. The program must be coded in Java. Other languages are also welcome, but there must be a Java version attached. This is my first Challenge. Others coming soon. Let's see who wins. This is a question in my school textbook. There it is given: [Hint: Use Math operators.]
16 odpowiedzi
+ 5
I can give highest 😥
[4, 7].max
#Ruby
+ 5
@Amrit
We can't use array.sort in java.util here, right? 😅
+ 4
@Kinshuk I did :/
It's a very easy way to do it
+ 4
@Limitless
I did the same, but then thought that the sort function may have some if in its code?
+ 4
@Limitless
Hmm.
You win!
+ 3
:/
+ 3
I made one super fast but it doesn't work in sololearn's IDE.. Not using sort
code.sololearn.com/cjdmOxNzJmtz/#java
+ 3
It probably does, but we did not write it and the question didn't say we can't use it ;)
+ 3
Awesome, thanks, can't wait for your next challange ;)
+ 3
https://code.sololearn.com/ca3eQnMUQ1t0/?ref=app
The same thing, without even using Arrays.sort(arr)...
+ 2
@Fredrick quickly share
+ 2
I don't know java but can't we do min and max and take the other?
+ 2
yes
That's what we did
+ 1
we wl use max nd min operations on all the 3 once we get to knw both the left is 2nd highest
+ 1
The next one
https://www.sololearn.com/discuss/489150/?ref=app