Home > Back-end >  Bubble sort the values of the output of some of the problems
Bubble sort the values of the output of some of the problems

Time:09-22

#include
using namespace std;
Int main ()
{
Int a [10], I;
Cout<& lt;" Plesae input 10 Numbers: "& lt; for(i=0; i<10; I++)
cin> A, [I].
Int j, s;
for(i=0; i<9. Bubble sort i++)//process
for(j=0; j<9 - I; J++)
{
If (a [I] & gt; A [I + 1])
S=a [I];
A [I]=a, [I + 1].
A [I + 1]=s;
}

Cout<& lt;" The result is: "& lt; If (a [0]=[1] a)//if equal number 1 and number 2
{
Coutfor(i=2; i<10; I++)//output remaining number
{
If (a [I]!=a [] I - 1)//repeat the number of output
Cout<& lt;" "& lt; }
Goto o;//program skip to end
}
The else
{
Coutfor(i=2; i<10; I++)
{
If (a [I]!=] [I - 1 a)
Cout<& lt;" "& lt; }
}


O: coutsystem("pause");
return 0;
}
This code is bubble sort, repeated output data of several output only once, consult everybody, thank you!

CodePudding user response:

You are two Numbers equal time should use the==, rather than=

CodePudding user response:

for(i=0; i<9. Bubble sort i++)//process
for(j=0; j<9 - I; J++)
To explain in detail what is the meaning of this thank you

CodePudding user response:

Sorting suggested tree, namely in the sequence search minimum value, then the first element and Swap; The iteration.

CodePudding user response:

Example a lot of books!
  • Related