1:题目来自拼题A第8题.<河南工程学院>
2:由于本题大部分由作者本人完成少部分参照资料;所以得了18分 少了两份
3:物联网专属,卢老师的<数据结构>
#include<stdio.h> //HMY自创--盗版必究,,, 全部为自己编写 ;
#include<stdlib.h> //觉得不错就赞下吧;
struct Sqlist{
int data;
struct Sqlist *next;
}sqlist;
int main()
{
struct Sqlist *L , *L1;
L=(struct Sqlist *)malloc(sizeof(struct Sqlist));
L1=(struct Sqlist *)malloc(sizeof(struct Sqlist));
L->next=NULL;
L1->next=NULL ;
int temp=1;
while(scanf("%d",&temp)!=EOF&&temp!=-1)
{ struct Sqlist *p,*he;
p=(struct Sqlist *)malloc(sizeof(struct Sqlist));
p->data=temp;
he=L;
while(he->next!=NULL)
{
he=he->next;
}
he->next=p;
p->next=NULL;
}
while(scanf("%d",&temp)!=EOF&&temp!=-1)
{ struct Sqlist *p,*he;
p=(struct Sqlist *)malloc(sizeof(struct Sqlist));
p->data=temp;
he=L1;
while(he->next!=NULL)
{
he=he->next;
}
he->next=p;
p->next=NULL;
}
struct Sqlist *p1,*p2;
p1=L;p2=L1;int i=0,num=0,cnt=0;
p1=p1->next;p2=p2->next;
while(p1!=NULL&&p2!=NULL)
{
if(p1->data<p2->data)
{
p1 = p1->next;
}
else if(p1->data == p2->data)
{//cnt为了规范输出
num++;
if(cnt == 0)
{
cnt = 1;
printf("%d",p1->data);
}
else
{
printf(" %d",p1->data);
}
p1 = p1->next;
}
else
{
p2 = p2->next;
}
}
if(num==0)
printf("NULL");
}
以上就是小编的全部代码啦.谢谢大家观看