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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include <stdio.h>
#include <stdlib.h>
#include "list.h"
Position FindNth( List L, int nth )
{
int i;
Position P;
P = L;
for( i = 0; i < nth && P != NULL; i++ )
{
P = P->Next;
}
return P;
}
void PrintLots( List L, List P )
{
int i;
Position Posi;
for( P = P->Next; P != NULL; P = P->Next )
{
Posi = FindNth( L, P->Element );
if (Posi != NULL)
{
printf("%d ", Posi->Element);
}
}
printf("\n");
}
int main()
{
List L, P;
L = malloc( sizeof( struct Node ) );
P = malloc( sizeof( struct Node ) );
Insert(6, P, P);
Insert(4, P, P);
Insert(3, P, P);
Insert(1, P, P);
Insert(8, L, L);
Insert(7, L, L);
Insert(6, L, L);
Insert(5, L, L);
Insert(4, L, L);
Insert(3, L, L);
Insert(2, L, L);
Insert(1, L, L);
PrintList( P );
PrintList( L );
PrintLots( L, P );
return 0;
}
|