KSC sort

#include <stdio.h>
#include <stdlib.h>


#define SIZE (10000)
int a[128]={0};
int b[SIZE]={0};
int l=0;
void test_main(char data[SIZE]) 
{
    for( int i=0;i<SIZE;i++){
        if(data[i]<0x80){
            a[data[i]]++;
        }
        if(data[i]>=0x80){
            b[l]=data[i];
            b[l+1]=data[i+1];
            l=l+2;
        }

    }
    for(int i=0;i<SIZE;)
    {
        if(data[i]<0x80)
        {
            asc[ascrear++]=data[i];
            i++;
            continue;
        }
        else
        {
            temp[0]=data[i];
            temp[0]=temp[0]&0x7F;
            temp[0]/4;

            temp[1]=data[i];
            temp[1]*=64;            
            temp[2]=data[i+1];                    
            temp[2]/32;
            temp[1]+=temp[2];

            temp[2]=data[i+1]&0x1F;

            sort[korrear]=long(temp[1]*1024+temp[2]*32+temp[0]);
            kor[0][korrear]=data[i];
            kor[1][korrear]=data[i+1];
            korrear++;
            i+=2;
        }
    }
    data[i]&0x80==0x80


}



static char data[SIZE];


static void build_data(void)
{
    int a;
    for (a = 0; a < SIZE; a++)
        data[a] = rand() % 128;
    for (a = 0; a < SIZE / 2; a++)
        data[rand() % (SIZE - 1)] = rand() % 256;
}


void main(void)
{
    for (int l = 0; l < 10; l++)
    {
        build_data();

        test_main(data);
        int sum = 0;
        for (int a = 0; a < SIZE; a++)
        {
            sum = ((sum << 8) & 0xffffff00) + ((sum & 0xff000000) >> 24);
            sum += data[a];
        }
        printf("%08X
", sum);
    }
}
原文地址:https://www.cnblogs.com/ZzznOoooo/p/6628077.html