Sorting array java -
Hello friends, I have a problem in my program, I have to call class and whether to write numbers in main parameters, To tell how many numbers will be printed and they should be the biggest one, the problem is that when I print some random numbers, if they are equal or some negative then they show only once and sometimes This is the biggest If it is not clear, then I will post code and an example. (A = 0; a & lt; array.lampper; a ++) for
{for (b = 0; b & lt; array.length-1; b ++) {If (array [b] & gt; array [b + 1]) {aux = array [b]; Array [b] = array [B + 1]; Array [B + 1] = aux; } I have used this code to sort them but I do not know it's okay. Ps: I can not use simple methods or objects just simple arguments.
I think that you have left some brackets here and there
First of all compare your if (array [B]> array [B + 1]) sort the highest to the highest. If you want it to be the highest to reduce, then you would want to change to if (array [B]> array [B + 1] is the code here To reduce the highest from an array.
For (int a = 0; a & lt; array; album; a ++) {for (int b = 0; b this is a bubble sort.
Comments
Post a Comment