60 429
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #652 in C# for Ram F

Question #652
I managed to create a random number generator, which generates 100 numbers from -20 to 20.
But now i need to rearrange them in a way that the positive numbers will be presented first, then the zeros, and then the negative numbers.
Step 1 is to generate the random numbers (which I managed to do) and step 2 is to press any key (ReadKey) and then the numbers will be rearranged in the way I just wrote about. How do i that?
First of all, fill the array [0..99] with the generated random numbers.
Then use ReadKey to assume that key was pressed.
After the key has been pressed, use &quot;bubble sorting&quot;, the pseudocode is following:
int temp;
for (int i = 0; i &lt; 99; i++) {
for (int i = 0; i &lt; 99; i++) {
if (your_array[i] &lt; your_array[i + 1]) {
temp = your_array[i];
your_array[i] = your_array[i + 1];
your_array[i + 1] = temp;
}
}
}

After the sorting, just output your array, and the positive numbers will be presented first, then the zeros, and then the negative numbers.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!