提交记录 6438


用户 题目 状态 得分 用时 内存 语言 代码长度
zhangjingyu 1001. 测测你的排序 Compile Error 0 0 ns 0 KB C 1.39 KB
提交时间 评测时间
2018-10-10 20:25:17 2020-08-01 00:43:49
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct list
{
    unsigned data;
    list* next;
};

struct aa
{
    list* head;
    list* tail;
} ans[65536];

unsigned findpos(unsigned num,unsigned jishu,int g)
{
    if(g == 0)
        return num&jishu;
    return num>>16;
}
void do_once(unsigned *a,int n,unsigned jishu,int g)
{
    int size = sizeof(list);

    memset(ans,0,sizeof(ans));
    for(int i = 0; i < n; i ++)
    {
        unsigned pos = findpos(a[i],jishu,g);
        //	unsigned pos = jishu&a[i];
        list *node = (list*)malloc(size);
        node->data = a[i];
        node->next = 0;

        if(ans[pos].head == 0)
        {
            ans[pos].head = node;
            ans[pos].tail = node;
            continue;
        }

        ans[pos].tail->next = node;
        ans[pos].tail = node;
    }
    int wp=0;
    for(int i = 0; i < 65536; i ++)
    {
        list *p = ans[i].head;
        list *now;
        while(p)
        {
           // printf("%u ",p->data);
            a[wp++] = p->data;
            now = p;
            p = p->next;
            free(now);
        }

    }
}

void sort(unsigned *a, int n)
{
    unsigned jishu = 65535;
    do_once(a,n,jishu,0);
    do_once(a,n,jishu,1);
}

int main()
{
    unsigned a[10] = {65536,1,982,4294901760,0,12,75532,900000,90,12};
    sort(a,10);
    for(int i = 0; i < 10; i++)
    {
        printf("%u ",a[i]);
    }

    return 0;
}


CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-10 03:10:45 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠