红河做网站的公司,网站设计需求文档范例,网站建设服务器 几核,公司没网站怎么做dspProblem Description 输入N个整数#xff0c;按照输入的顺序建立单链表存储#xff0c;并遍历所建立的单链表#xff0c;输出这些数据。Input 第一行输入整数的个数N#xff1b; 第二行依次输入每个整数。Output 输出这组整数。Example Input 8
12 56 4 6 55 15 33 62 Exam… Problem Description 输入N个整数按照输入的顺序建立单链表存储并遍历所建立的单链表输出这些数据。Input 第一行输入整数的个数N 第二行依次输入每个整数。Output 输出这组整数。Example Input 8
12 56 4 6 55 15 33 62 Example Output 12 56 4 6 55 15 33 62 #include stdio.h #include stdlib.h struct node { int data; struct node *next; }*head,*tail,*p; void print(struct node *h) { struct node *ph-next; while(p!NULL) { printf(%d ,p-data); pp-next; } } struct node *create(int n) { int i; head(struct node *)malloc(sizeof(struct node)); head-nextNULL; tailhead; for(i1;in;i) { p(struct node *)malloc(sizeof(struct node)); scanf(%d,p-data); p-nextNULL; tail-nextp; tailp; } return head; } int main() { int n; scanf(%d,n); struct node *h; hcreate(n); print(h); return 0; }