#include<stdio.h>
#include<stdlib.h>
struct output{
int data; //数据域
struct output* next; //指针域
};
//创建新结点的结构体指针
void creat_newcode( struct output *head, int n){
for(int i = 1;i == 1;){
if(n!=0){
struct output *newtie = NULL;
newtie = (struct output*)malloc(sizeof(struct output));//分配空间
scanf("%d",&(newtie->data));//传入数据域
head->next = newtie;//链接
printf("%d ",newtie->data);
creat_newcode(newtie , n-1);}
i--;
}
}
int main(){
int n;
scanf("%d\n",&n);
struct output *head = NULL;//创建头指针
head = (struct output*)malloc(sizeof(struct output));//给头指针分配空间
creat_newcode(head,n);
return 0;
}
#include<stdlib.h>
struct output{
int data; //数据域
struct output* next; //指针域
};
//创建新结点的结构体指针
void creat_newcode( struct output *head, int n){
for(int i = 1;i == 1;){
if(n!=0){
struct output *newtie = NULL;
newtie = (struct output*)malloc(sizeof(struct output));//分配空间
scanf("%d",&(newtie->data));//传入数据域
head->next = newtie;//链接
printf("%d ",newtie->data);
creat_newcode(newtie , n-1);}
i--;
}
}
int main(){
int n;
scanf("%d\n",&n);
struct output *head = NULL;//创建头指针
head = (struct output*)malloc(sizeof(struct output));//给头指针分配空间
creat_newcode(head,n);
return 0;
}