#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
struct node
{
int inum;
struct node *next;
};
struct node *create(int n)
{
struct node *head,*p;
int i;
head = (struct node *)malloc(sizeof(struct node));
head->next = NULL;
for(i = 1;i <= n;i++)
{
p = (struct node *)malloc(sizeof(struct node));
scanf("%d",&p->inum);
p->next = head->next;
head->next = p;
}
return (head);
}
void print(struct node *head,int n)
{
struct node *p;
int i;
p = head->next;
for(i = 1;i < n;i++)
{
printf("%d ",p->inum);
p = p->next;
}
printf("%d\n",p->inum);
}
int main()
{
struct node *Head;
int N;
scanf("%d",&N);
Head = create(N);
print(Head,N);
return 0;
}
sdut.acm2012级《程序设计基础Ⅱ)》_链表 数据结构实验之链表二:逆序建立链表
最新推荐文章于 2020-03-16 10:50:58 发布