# 链表查找(线性表)

#include <iostream>
using namespace std;
struct list
{
int data;    //数据域
};
struct list *listcreate(struct list *head,int n)    //建立链表
{
struct list *previous;    //前驱结点
struct list *current;    //当前结点
if(n<1)
return NULL;    //建立空链表
while(--n)
{
current=new struct list;    //建立新结点
cin>>current->data;            //输入数据
previous=current;
}
}

struct list *minmovefirst(struct list *head)    //将最小结点移至表尾
{
struct list *minnode;    //最小结点
struct list *previousminnode;    //最小结点的前驱结点
struct list *previous;    //前驱结点
struct list *current;    //当前结点
/************查找最小结点*****************/
while(NULL!=current)
{
if(current->data<minnode->data)    //结点数据比较
{
/*
请在该部分填写缺少的代码
*/

}
previous=current;        //记录前驱结点
}
//此时的previous指向表尾
/************从链表摘下最小结点*****************/
else

/************将最小结点放在表头*****************/
}
{
while(current!=NULL)
{
cout<<current->data<<" ";    //输出结点数据
}
}
int main()
{
int n;
cin>>n;
return 0;
}

输入数据：4 2 6 88 34 6

2 4 6 88 34 6

``````5
11 6 8 7 9``````

``6 11 8 7 9 ``

``````#include <stdio.h>#include <stdlib.h>
struct u_node_s
int main()
struct u_node_s *current;
struct u_node_s *temp;int n = 0;
int i = 0;
scanf("%d", &n);
current = link = (struct u_node_s *)
malloc(sizeof(struct u_node_s));
for(i = 0; i < n; i++)
{temp = (struct u_node_s *)malloc(sizeof(struct u_node_s));
scanf("%d", &(temp->data));
return 0;}
``````

``````#include <stdio.h>#include <stdlib.h>
struct u_node_s
int main()
struct u_node_s *current;
struct u_node_s *temp;int n = 0;
int i = 0;
scanf("%d", &n);
current = link = (struct u_node_s *)
malloc(sizeof(struct u_node_s));
for(i = 0; i < n; i++)
{temp = (struct u_node_s *)malloc(sizeof(struct u_node_s));
scanf("%d", &(temp->data));