#include<iostream> #include<stdlib.h> using namespace std; struct Node { int data; struct Node *next; }; int main() { int num,n; cin>>num; Node *head,*p; head=NULL; head = p = (Node*)malloc(sizeof(struct Node)); for(int i=0;i<num;i++) { p->next=(Node*)malloc(sizeof(struct Node)); cin>>n; p->data=n; p=p->next; } p->next=NULL; for(p=head;p->next!=NULL;p=p->next) { cout<<p->data; } }
标签:Node,结点,struct,int,一个头,head,next,链表 From: https://www.cnblogs.com/weinan030416/p/16804331.html