/*
静态链表:用数组的方式实现的链表
*/
#include <cstdio>
#include <iostream>
#include <cstdlib>
using namespace std;
#define ElemType int
#define MaxSize 10
//声明方法1
typedef struct {
ElemType data;
int next;
}SLinkList1[MaxSize];
//声明方法2
struct Node {
ElemType data;
int next;
};
typedef struct Node SLinkList2[MaxSize];
int main() {
struct Node node;
SLinkList1 list1;
struct Node list2[MaxSize];
SLinkList2 list3;
printf("size of int:%d\n", sizeof(int));
printf("size of ElemType:%d\n", sizeof(ElemType));
printf("size of Node:%d\n", sizeof(node));
printf("size of list1:%d\n", sizeof(list1));
printf("size of list2:%d\n", sizeof(list2));
printf("size of list3:%d\n", sizeof(list3));
return 0;
}
数据结构C++实现——线性表之链表(静态链表)
最新推荐文章于 2024-08-27 20:47:22 发布