-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaap26.c
42 lines (42 loc) · 861 Bytes
/
aap26.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<stdio.h>
#include<stdlib.h>
struct node
{
int d;
int v;
struct node *link;
};
struct node * insert(struct node *start,int v,int d)
{
struct node *p,struct node *tmp=(struct node *)malloc(sizeof(struct node));
tmp->v=v;
tmp->d=d;
tmp->link=NULL;
if(start==NULL)
{
start=tmp;
return start;
}
p=start;
while(p->link!=NULL)
p=p->link;
p->link=tmp;
return start;
}
int main()
{
struct node *start1=NULL,*start2=NULL,*start3=NULL;
printf("Enter the no of nodes in list 1 :");
scanf("%d",&n1);
for(i=0;i<n1;i++)
{
scanf("%d%d",&v,&d);
start1=insert(start1,v,d);
}
printf("Enter the no of nodes in list 2 :");
scanf("%d",&n2);
for(i=0;i<n1;i++)
{
scanf("%d%d",&v,&d);
start2=insert(start2,v,d);
}