桶排序-C-结构体排序

    struct TS {
int index;
char name[];
}; struct TS b[] = {{,"s5"},{,"s2"},{,"s3"},{,"s1"},{,"s8"}}; struct TS a[];
int i;
int length = sizeof(a) / sizeof (struct TS);
for(i=;i<length;i++){
struct TS tmp = {,""};
a[i] = tmp;
} for (i=; i<; i++) {
int num = b[i].index;
if(a[num].index >= ){
a[num] = b[i];
}else{
struct TS tmp = {,""};
a[num] = tmp;
}
} for (i=; i<; i++) {
if(a[i].index)
printf("%s\n",a[i].name);
}
上一篇:ContentObserver监听数据库·变化


下一篇:java.util.NoSuchElementException