双向链表相同值查询设计

来源:百度知道 编辑:UC知道 时间:2024/05/27 17:57:48
构建二个双向链表,能够根据第一个表中的值查询在第二个表中相同值的位置

大家帮帮我
要用C语言实现编程

#include<stdio.h>
struct node
{
int value;
node * next; // 向后指针
node * before; //向前指针
};
void main()
{
node * head_1,*head_2,*tempp,*tempp2;
int i,temp,count;
head_1=head_2=NULL;
printf("输入5个整数 用空格分开 \n");
for(i=0;i<5;i++) //构建链表一
{
scanf("%d",&temp);
tempp=head_1;
head_1=new(node);
head_1->value=temp;
head_1->next=tempp;
if(tempp!=NULL)
tempp->before=head_1;
head_1->before=NULL;

}

printf("请输入刚才输入的五个数,顺序不同 \n");
for(i=0;i<5;i++) //构建链表一
{
scanf("%d",&temp);
tempp=head_2;
head_2=new(node);
head_2->value=temp;
head_2->next=tempp;
if(tempp!=NULL)
tempp->before=head_2;
head_2->before=NULL;

}
////////////////////////////