import java.util.Arrays;
/*
* Created on 2012-3-12
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author hongbin.mu
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Px {
private int[] array;
/**
* @return Returns the array.
*/
public int[] getArray() {
return array;
}
/**
* @param array The array to set.
*/
public void setArray(int[] array) {
this.array = array;
}
public Px(int[] array){
this.array=array;
}
public void sort(){
for(int i=1;i<array.length;i++){
if(array[i]!=0){
int k=i;
while(k>0){
if(array[k]<array[k-1]){
int temp = array[k];
array[k]=array[k-1];
array[k-1]=temp;
}else{
break;
}
k--;
}
}
}
}
public static void main(String[] args) {
Array ars= new Array(10,8);
Px px= new Px(ars.getArray());
px.sort();
System.out.println(Arrays.toString(px.getArray()) );
}
}
/*
* Created on 2012-3-12
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author hongbin.mu
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Array {
private int[] array;
/**
* @return Returns the array.
*/
public int[] getArray() {
return array;
}
/**
* @param array The array to set.
*/
public void setArray(int[] array) {
this.array = array;
}
public Array(int cout,int num){
array=new int[cout];
for(int i=0;i<num;i++){
array[i]=(int)(Math.random()*100);
// System.out.println(array[i]);
}
}
}