#include <stdio.h>
#include <stdlib.h>
typedef struct Link
{
int elem
;
struct Link
* next
;
}link
;
link
* initLink(){
link
*p
= NULL;
link
*temp
= (link
*)malloc(sizeof(link
));
temp
->elem
= 1;
temp
->next
= NULL;
p
= temp
;
for(int i
=2;i
<5;i
++){
link
*a
=(link
*)malloc(sizeof(link
));
a
->elem
= i
;
a
->next
= NULL;
temp
->next
= a
;
temp
= temp
->next
;
}
return p
;
}
void display(link
*p
){
link
*temp
= p
;
while(temp
){
printf("%d ",temp
->elem
);
temp
=temp
->next
;
}
printf("\n");
}
void reserve(link
*p
){
while(p
->next
!=NULL&&)
}
int main(){
printf("链表初始化:\n");
link
*P
=initLink();
display(P
);
return 0;
}
转载请注明原文地址: https://mac.8miu.com/read-493964.html