1.知识点:逆序建立链表
2.题意:输入整数个数N,再输入N个整数,按照这些整数输入的相反顺序建立单链表,并依次遍历输出单链表的数据
3.注意事项:指针移动、动态申请内存
代码:
#include <stdio.h>
#include <stdlib.h>
typedef struct st
{
int num;
struct st *next;
}str;
int main()
{
int n, i;
str *head, *p;//定义str类型的指针:头指针head, 游动指针p
head = (str *)malloc(sizeof(str));//为head动态申请空间
head -> next = NULL;//构建最简链表
sca