In decreasing order

  • 5
  • Locked
The ordered isomorphs of Planet Linear Chaos love to sort and accept into their ranks those who are proficient at sorting. What's that you say? You don't plan on associating with them? That won't work: isomorphs are often the ones conducting interviews at IT companies. We won't ignore them: write a program that reads 20 numbers from the keyboard and displays them in decreasing order.
You can't complete this task, because you're not signed in.
Comments (12)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 15 , Old Town, United States
26 April 2021, 15:57
This task was like task 0622. It can be done with a simple Collection, but it was good to do it with nested loops, to understand the logic behind it. I didn't understand the logic behind int j = i at first, but when I wrote it out, I understood it. Fun exercise! Happy coding :)
Level 11 , Banja Luka, Bosnia and Herzegovina
4 March 2021, 21:16
Change int to Integer. Use collections reverse sort. Done. This won't be acceptable solution according to the requirements (since they want int, not Integer), but who cares. Problem solved without unnecessary complications like nested loops.
Mitesh Shah
Level 11 , London, United Kingdom
24 January 2020, 20:57
My code works, and it verifies correctly, but I am still confused. The sort method is void. It is not returning anything. So how is the sorted array being printed in the correct decreasing order?
Nickolas Johnson
Level 8 , St. Louis, United States of America
4 April 2020, 14:02
Yeah, I don't get it either. I expected to have to print it out in the sort method.
Level 27 , Spanish Town, Jamaica
25 April 2020, 08:24
the sort method is void, so it doesn't have a data type to return. when we call the function "sort(array)" we pass it a copy of the array and the code in that method changes the array's 'internal state' (sorts it in descending order).
Mitesh Shah
Level 11 , London, United Kingdom
28 April 2020, 13:16
Thanks, that clears it up for me.
Level 10
29 April 2020, 00:42
remember when we use array its a reference point to an object, so whenever we touch that same object in different methods, what is in the array will change.
Roman Grygorczuk
Level 19 , Cracow, Poland
31 October 2020, 20:25
this will explain what is going on
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
25 November 2019, 05:06
It is still frustrating when I meet what I think are the requirements, but does not verify. I used collections sort then reversed. codegym did not like that. wants me to make my own sorting I did that and it passed. Okay because I learned two ways to do it.
Level 19 , Aptos, United States
17 September 2019, 09:25
why ? i think i'm right. plz help me
Level 14 , Apeldoorn, Netherlands
14 July 2019, 15:35
Wait we can use the names sorting algorithms?
Level 16 , Toronto, Canada
4 February 2019, 11:47
Hint: Bubble Sort