# define n 10
#include
using namespace std;
Int main ()
{
Int I, j;
99,89,79,69,59,49,39,29,19,9 int a [n]={};
For (j=1; J & lt; N; J++)
{
For (I=0; i
If (a [I] & gt; A [I + 1])
{
Int swap;
Swap=a, [I].
A [I]=a, [I + 1].
A [I + 1)=swap;
}
}
cout <"The first" & lt;
cout }
cout
return 0;
}
The above code execution results:
The great god, please help to show me the idea is in line with the programming logic and practicability, thank you very much
CodePudding user response:
As long as the cycle number for you from any initial value cycle can be love, so that you deal with no problem,CodePudding user response:
Need to see is people do not represent the round but from an array subscript 0, so understanding deviation, your approach should accord with starting from the subscript 0 and achieve the subscript to the end of the can, truth is the same, as for how to write a variety of reason must be the same,CodePudding user response:
Understanding deviation, bubbling cycle the outermost variables (assuming I) represents an array subscript, such as PHP, golang, the first element of the array subscript is 0, so I usually start from zero, so array [I] is the first element, if the first element of the array subscript is 0, I begin from 1, so when you take the first element of the array with array [] I - 1