#include <stdio.h>
typedef struct Node{
int data;
struct Node *next;
}LNode,*pNode;
void createlinkhead(pNode head,int n){
for(int i=0;i<n;i++){
pNode temp = (pNode)malloc(sizeof(LNode));
temp->data = i+1;
temp->next = NULL;
temp->next=head->next;
head->next=temp;
}
}
void printlink(pNode head){
pNode p=head->next;
while(p){
printf("%d\t",p->data);
p=p->next;
}
}
int main(){
pNode head = (pNode)malloc(sizeof(LNode));
head->data=0;
head->next=NULL;
createlinkhead(head,10);
printlink(head);
}
//
// Created by yhk on 2023/5/22.
//
#include "stdio.h"
#include <stdio.h>
typedef struct Node{
int data;
struct Node *next;
}LNode,*pNode;
void createlinkrear(pNode head ,int n){
pNode r=head;
for(int i=0;i<n;i++){
pNode temp = (pNode)malloc(sizeof(LNode));
temp->data=i+1;
temp->next=NULL;
r->next=temp;
r=r->next;
}
}
void print(pNode head){
pNode r=head;
while(r){
printf("%d\t",r->data);
r=r->next;
}
}
int main(){
pNode head = (pNode)malloc(sizeof(LNode));
head->data=0;
head->next=NULL;
createlinkrear(head,10);
print(head);
}