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)
3
-61.2
-0.1
-28.7
Problem statement/test cases have been fixed.
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."
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.