#include <bits/stdc++.h>
using namespace std;
struct node
{
int data;
node* next;
};
node* create()
{
int num;
node*t;
cin>>num;
if(num==0)
t=NULL;
else
{
t=new node[1];
t->data=num;
t->next=create();
}
return t;
}
int main()
{
node* head;
head=create();
node*p=head;
while(p!=NULL)
{
cout<<p->data<<" ";
p=p->next;
}
}
原文:https://www.cnblogs.com/baccano-acmer/p/9769923.html