• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
crucio
博客园    首页    新随笔    联系   管理    订阅  订阅
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\n", sum);
    }
}

 

posted on 2017-03-27 18:13  crucio  阅读(149)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3