位图排序(计数排序)

void countSort(int &array) 
{ 
       int N = 1000000;
       int i ;
       double bit = 0 ;
       //用一个字符串来表示位向量 
       //先初始化位向量 
       //使用逻辑运算实现位向量,在保证其他位不变的情况下,将某位变成1,应该使用或运算,改变位为1,其他位都为0。使用移位运算 
        for( i = 0 ; i < N ; ++i) 
               bit |= ( 1 << array[i] ) ; 
        //再进行输出 
         for( i = 0 ; i < N ; ++i ) 
        //判断某一位是否是1,同样用移位运算,用1对该位进行“与”运算 
                 if( bit & ( 1<<i ) ) OUT i ; }
原文地址:https://www.cnblogs.com/trying/p/2863840.html