struct stu * create() { int m; scanf("%d", &m); //输入结点个数 struct stu *head = NULL, *tail = NULL; for (int i = 0; i < m; i++) { struct stu *p = (struct stu *)malloc(sizeof(struct stu)); scanf("%s %d", p->name, &(p->no)); //输入结点信息 p->next = NULL; if (head == NULL) //如果当前结点是第一个结点 { head = p; tail = p; } else //如果当前结点不是第一个结点 { tail->next = p; //将当前结点挂在链表尾部 tail = p; //更新链表尾指针 } } return head; //返回链表头指针


原文地址: https://www.cveoy.top/t/topic/cFGu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录