#include
#include
using namespace std;
Struct LinkNode
{
int data;
Struct LinkNode * next;
};
Void CreateListR (LinkNode * & amp; L, int a [], int n)
{
LinkNode * r * s;
L=(LinkNode *) malloc (sizeof (LinkNode));
r=L;
for(int i=0; i
S=(LinkNode *) malloc (sizeof (LinkNode));
S - & gt; data=https://bbs.csdn.net/topics/a [I];
R - & gt; Next=s;
r=s;
}
R - & gt; Next=NULL;
}
Void CreateList (LinkNode * & amp; L, int a [], int n)
{
LinkNode * s;
L=(LinkNode *) malloc (sizeof (LinkNode));
L - & gt; Next=NULL;
for(int i=0; i
S==(LinkNode *) malloc (sizeof (LinkNode));
S - & gt; data=https://bbs.csdn.net/topics/a [I];
S - & gt; Next=L - & gt; Next;
L - & gt; Next=s;
}
}
Void DisList (LinkNode * L)
{
LinkNode * p=L - & gt; Next;
while(p!=NULL)
{
Printf (" % d ", p - & gt; The data);
P=p - & gt; Next;
}
printf("\n");
}
The main ()
{
Int a [5]=,1,2,3,4 {0}.
Int b [5]={5,6,7,8,9};
Int n=5;
LinkNode * L * r;
CreateListR (L, a, n);
CreateList (r, b, n);
DisList (L);
DisList (r);
}
CodePudding user response:
A s==createlist inside you