public class Solution
{
    public static void main(String[] args) throws Exception
    {
        //add your code here
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int[] lista=new int[10];

        //fill array with int values from keyboard
        for (int i=0; i<lista.length; i++) {
            lista[i]=Integer.parseInt(reader.readLine());
        }
        // sort array
        boolean sorted=false;
    while (!sorted) {
        sorted=true;
        for (int i=0; i<(lista.length-1); i++) {
            if (lista[i]<lista[i+1]) {
                int temp = lista[i];
                lista[i]=lista[i+1];
                lista[i+1]=temp;
                sorted=false;
            }
        }
    }
        //display sorted array
        for (int i=0; i<lista.length; i++) {
        System.out.println(lista[i]);
    }
    }
}

I have no idea why this one does not pass the test. I hate the fact that it's only 10 levels avilable and I'm already in 7th. This is the best course ever!!!! I helped myself reading next lesson. I understood the task wrong. It didn't mean to sort the numbers descending and display it but just to arrange the elements in reverse order as they were input (the last element goes first, the second from end becomes secont etc).

asked 29 Dec '17, 15:10

spike's gravatar image

spike
11
accept rate: 0%

edited 31 Dec '17, 11:02

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×60
×7
×4

Asked: 29 Dec '17, 15:10

Seen: 47 times

Last updated: 31 Dec '17, 11:02