smth 1.2的代码部分,bless版的十大调用sortbless,这是原来的sort
sort被修改成一个版只能一个,比较粗暴,不能定制一个版出几个十大
代码由ada@lsxk 完成
int sortbless(pp, count)
struct postrec *pp;
{
int i, j;
for (i = 0; i <= count; i++) {
if (pp->number > top[i].number) {
if (count < TOPCOUNT - 1)
count++;
for (j = count - 1; j >= i; j--)
memcpy(&top[j + 1], &top[j], sizeof(struct posttop));
memcpy(&top[i], pp, sizeof(struct posttop));
break;
}
}
return count;
}
int sort(pp, count)
struct postrec *pp;
{
int i, j, k;
for (i = 0; i <= count; i++)
{
if((!strcmp(pp->board, top[i].board) && !(pp->number > top[i].number)))
{
break;
}
else if (pp->number >top[i].number)
{
if (!strcmp(pp->board, top[i].board))
{
memcpy(&top[i], pp, sizeof(struct posttop));
break;
}
else
{
if (count < TOPCOUNT - 1)
count++;
for (j = count - 1; j >= i; j--)
{
memcpy(&top[j + 1], &top[j], sizeof(struct posttop));
}
memcpy(&top[i], pp, sizeof(struct posttop));
//执行删除操作
for (j = i+1; j <= count; j++)
{
if (!strcmp(pp->board, top[j].board))
{
for (k=j+1; k <= count; k++)
memcpy(&top[k-1], &top[k], sizeof(struct posttop));
count--;
}
}
break;
}
}
}
return count;
}
【 在 cnbird (阿七) 的大作中提到: 】
: 出手吧,我从来没看懂过那里怎么限制的
--
FROM 222.18.13.*