package hu.paixu;

 

public class BitMap {

 

public static void main(String[] args) {

int nums[]={15,1,55,6,22,48,3,2,51};

sort(nums);

for(int i=0;i<nums.length;i++){

System.out.print("<"+nums[i]);

}

}

 

//数组元素必须是无重复的整数

public static void sort(int array[])//排序算法

{

int max=55;//要排序的数字最大值55

byte[] temp =new byte[max];//生成55个元素的byte数组

for(int i=0;i<array.length;i++)

{

temp[array[i]]=1; //若索引在要排序的数组中就把byte数组值标记为1;否则为0;

}

 

for(int j=0,k=0;k<max;k++)

{

if(temp[k]==1)//看看byte数组中是否为1;

{

array[j++]=k;//若为1则将索引值写入原数组,就排好了

}

}

}

 

}

出處:http://hi.baidu.com/hzyws/item/5fa69675cce8af2fd7a89ca8(感謝原作者)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-21
  • 2022-12-23
  • 2022-01-16
  • 2022-03-04
  • 2021-06-04
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案