// 结构体嵌套.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include "stdlib.h"#include #include using namespace std;struct teacher{int data;struct teacher *next;};teacher *creatlist(){teacher t1, t2, t3;teacher *p = NULL;//初始化t1.data = 1;t2.data = 2;t3.data = 3;t1.next = &t2;t2.next = &t3;t3.next = NULL;//静态链表p = &t1;//指针遍历链表while (p){printf("data:%d\n", p->data);p = p->next;}return &t1;}int main(){teacher *head = creatlist();system("pause"); return 0;}
C++链表定义
最新推荐文章于 2023-08-06 14:33:25 发布