冒泡排序时间复杂度,O(n2),空间复杂度O(1)
package com.test.cn;
public class test1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Integer i=0, temp=0, j =0;
int a[] = {1,2,3,4,5,6,7,8,9,10};
for(i=0; i < 10; i++)
{
System.out.println("a["+i+"]="+String.valueOf(a[i]));
}
for(i=0; i<10; i++)
{
for(j=0;j<10-i-1;j++)
{
if(a[j]<a[j+1])
{
temp = a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(i=0; i < 10; i++)
{
System.out.println("a["+i+"]="+String.valueOf(a[i]));
}
return ;
}
}