小编use*_*441的帖子

冒泡排序双链表

我的双向链表的泡泡分类功能有问题.当我以单链接的方式对节点进行排序时(仅使用 - > next),它正在工作,但我无法使用 - > prev指针.这是我正在使用的代码:

void sort(int count)
{
    struct data *tmp,*current,*nextone;
    int i,j;
    for(i=0;i<count;i++)
    {
        current = first;
        for(j=0;j<count-1-i;j++ )
        {
            if(current->number > current->next->number)
            {
                nextone = current->next;
                current->next = nextone->next;
                nextone->next = current;
                if(current == first)
                {
                    first = nextone;
                    current = nextone;
                }
                else
                {
                    current = nextone;
                    tmp->next = nextone;
                }
            }
            tmp = current;
            current = current->next;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的结构(使用列表的第一个和最后一个元素的全局变量):

struct data    
{
    int id;
    char name[20];
    int number;
    struct data *next; …
Run Code Online (Sandbox Code Playgroud)

c sorting list bubble-sort doubly-linked-list

2
推荐指数
1
解决办法
2万
查看次数

在另一个网站上搜索元素

我想创建一个代码,它将检入另一个网页源代码,如果提供的值(例如,在输入框中,通过单击按钮激活检查)已经在选项中(在选择菜单中),并显示警报如果有的话.

我尝试在jQuery中这样做,但我以前从未尝试过这个,所以我失败了.:/也许你知道如何做到这一点?

html javascript jquery

1
推荐指数
1
解决办法
947
查看次数

标签 统计

bubble-sort ×1

c ×1

doubly-linked-list ×1

html ×1

javascript ×1

jquery ×1

list ×1

sorting ×1