BlueBook

p118ex5 - Max is Last

Write a program where you are given a list of N distinct real numbers where 0 ≤ N ≤ 100. Take the largest item of the list and print it last. All other items in the list should remain in their original order.

Input

The first line of input will be an integer, N (0 ≤ N ≤ 100). Next will be N real numbers.

Output

Output the largest number at the end rounded to two decimal places. Do not rearrange the rest of the numbers and output them as inputted (rounded to two decimal places).

Sample Input

4
3
2.7
5.12
-0.63

Sample Output

3.00
2.70
-0.63
5.12

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 19, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

Can someone tell me why the second output for me is just 0?

Try this test case:

3
-61.2
-0.1
-28.7

I tried the test case and it works exactly. I tried some of my own as well and it works but for some reason the judge doesn't accept case 2 and 3. Can someone look at it and tell me what I am missing?

Try not to remove elements of the list while iterating over it

OK, it really didn't make sense before.
Problem statement/test cases have been fixed.

The example is retarded... its not even in order

I beg to differ.

It doesn't say anything about being in increasing order (I assume that's what you mean). Maybe you should read the problem statement more carefully next time.

Here's the "full" statement, since it's kind of cut off.

"Write a program to find the largest value in a collection of N real numbers, where the value of N is the first data item read by your program. The program should first print all of the numbers entered, in order, except for the largest item. Then, it should print the largest of the numbers entered."

shouldn't the output be:

3.00
2.70
-0.63
5.12

Even though its the same as the input, its still in order from first to last entered, with the largest last.


wait, how do u do this question. Do you output it one by one, or wait until u have all the imputs?