我编写了冒泡的算法最终的结果却不是对的这是什么原因呢
package 随意;
public class Xunhuan {
public static void main(String[] args){
int score[]={70,80,90,85,76,95,94,85,72,83};
int i,j;
int temp;
for(i=0;i
for(j=0;j
{
if(score[i]>score[i+1]){
temp=score[j];
score[j]=score[j+1];
score[j+1]=temp;
}
}
System.out.print("按从小到大排序后数组元素为:");
for(i=0;i<score.length;i++)
System.out.println(score[i]+"");
}
}
结果却是
按从小到大排序后数组元素为:76
80
85
70
90
95
94
85
72
83