交集问题(线性表)

1 4 5 6 7 8

1 3 6 9 10 33

1 6

``````11 14 54 6 4 83

11 3 6 9 10 83
``````

``11 6 83 ``

``````#include <stdio.h>
#include <stdlib.h>
typedef struct s
{
int date;
}S;
S *creat(int n)
{
scanf("%d",&p->date);
while(--n)
{
p=malloc(sizeof(S));
scanf("%d",&p->date);
q=p;
}
}
void play(S *a,S *b)
{
S *p,*q,*r=a;
{
if((p->date)==(q->date))
{
r->date=p->date;
break;
}
}
printf("%d ",r->date);
}
int main()
{
return 0;
}``````

``````#include<stdio.h>
#include<cstring>
#include <stdlib.h>
typedef struct s
{
int date;
}S;
S *creat()
{
char str1[100],str2[80];
int len = 0,len1,a[10],b,i=0;
int n=-1;
gets(str1);
len1=strlen(str1);
while(n){
sscanf(str1+len,"%s",str2);
sscanf(str2,"%d",&n);
a[i]=n;
len+=strlen(str2);
while(str1[len]==' ')
len++;
i++;
//printf("%4d",n);
if(len>=len1)
break;
}
b=i-1;
i=0;
p->date=a[i];
while(b--)
{ 	i++;
p=(S*)malloc(sizeof(S));
p->date=a[i];
q=p;

}
}
void play(S *a,S *b)
{
S *p,*q,*r=a;
{
if((p->date)==(q->date))
{
r->date=p->date;
break;
}
}
printf("%d ",r->date);
}
int main()
{
char s[10];