Home > Back-end >  Pray god give directions! Thank humbly! Bubble no cycle is according to the book I taught a step of
Pray god give directions! Thank humbly! Bubble no cycle is according to the book I taught a step of

Time:09-26


Package hellojava;

Public class paixu {
Public static void main (String [] args) {//bubble sort
Int a []=,32,23,58,3 {1};
for(int i=1; ifor(int j=0; jIf (a [j] <+ 1 a [j]) {
Int b=a, a + 1 bonus to [j].
A [j + 1)=b;
}
}
}
System. The out. Println (" bubble sort is: ");
For (int b: a) {
System. The out. Print (b + "");
}




}


}
For everyone a great god help me with this code is wrong, thank humbly!

CodePudding user response:

The
If (a [j] <+ 1 a [j]) {
Int b=a, a + 1 bonus to [j].
A [j + 1)=b;
}
Change
If (a [j] <+ 1 a [j]) {//exchange a [j] and a [m + 1]
Int b=a, [j].
A [j]=a, a + 1 bonus to [j].
A [j + 1)=b;
}

CodePudding user response:

refer to the original poster java_mengxing response:
please everyone a great god help me with this code is wrong, thank humbly!


You should see the missing

Int b=a, a + 1 bonus to [j].
A [j + 1)=b;

This is no exchange!

CodePudding user response:

reference 1st floor qybao response:
put
If (a [j] <+ 1 a [j]) {
Int b=a, a + 1 bonus to [j].
A [j + 1)=b;
}
Change
If (a [j] <+ 1 a [j]) {//exchange a [j] and a [m + 1]
Int b=a, [j].
A [j]=a, a + 1 bonus to [j].
A [j + 1)=b;
}


Thanks to the great god problem has been resolved

CodePudding user response:

refer to the second floor qq_39936465 response:
Quote: refer to the original poster java_mengxing response:


For everyone a great god help me with this code is wrong, thank humbly!


You should see the missing

Int b=a, a + 1 bonus to [j].
A [j + 1)=b;

This is no exchange!


wrote a [j]=less a, a + 1 bonus to [j].

CodePudding user response:

Beginners can use the System. The out. Print in the location specified print do you want to see the value of a variable,
After look at the debug, the more convenient,
  • Related