package com;
public class ArraySort {
/**
* @param args
*/
public static void main(String[] args) {
int [] arr = {2,5,0,34,8,9};
int t;
int j=arr.length;
for(int i=0;i
if(j>=i) {
t=arr[i];
arr[i]=arr[--j];
arr[j]=t;
}else{
break;
}
}
for(int k=0;k
}
}
}
package
com;
public
class
ArraySort
{
/**
*
@param
args
*/
public
static
void
main(String[]
args)
{
int
[]
arr
=
{2,5,0,34,8,9};
int
t;
int
j=arr.length;
for(int
i=0;i
if(j>=i)
{
t=arr[i];
arr[i]=arr[--j];
arr[j]=t;
}else{
break;
}
}
for(int
k=0;k
System.out.print(arr[k]+"
");
}
}
}
冒泡法
看了一眼楼上写的,大致正确~