标签:printf nod def eof next \n nbsp 创建 oid
#include <stdio.h> #include <stdlib.h> typedef struct Node { int data; struct Node *next; }Node; Node* CreatList(int n) { Node *head,*p,*q; head=(Node*)malloc(sizeof(Node)); q=head; for(int i=0;i<n;i++) { p=(Node*)malloc(sizeof(Node)); scanf("%d",&p->data); p->next=NULL; q->next=p; q=p; } return head; } void Print(Node *head) { Node *p=head->next; while(p!=NULL) { printf("%d\n",p->data); p=p->next; } } int main() { int n; scanf("%d",&n); Node *p=CreatList(n); Print(p); }
标签:printf nod def eof next \n nbsp 创建 oid
原文地址:https://www.cnblogs.com/xyfs99/p/10347219.html