顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

seqList.h

#ifndef SEQLIST_H

#define SEQLIST_H

/*

struct sequence seqList{

int data[30];

int len;

};

*/

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#define MAX 30

typedef int Datatype;

typedef struct sequence

{

Datatype data[MAX];

int len;

}seqList,*seqListptr;

seqListptr seq_create();

#endif

seqList.c

#include<stdio.h>

#include"seqList.h"

seqListptr seq_create()

{

seqListptr S =(seqListptr)malloc(sizeof(seqListptr));

if (NULL==S)

{

printf("创建失败\n");

return NULL;

}

else

{

printf("创建成功\n");

S->len;//len会生成随机数需要清空

memset(S->data,0,sizeof(S->data));

return S;

}

}

main.c

复制代码
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "seqList.h"
int main(int argc, const char *argv[])
{
	
	seqListptr A=seq_create();
	return 0;
}
相关推荐
cookies_s_s4 小时前
B树(B-树)
数据结构·b树
And_Ii5 小时前
LeetCode 3397. 执行操作后不同元素的最大数量
数据结构·算法·leetcode
。TAT。5 小时前
C++ - List
数据结构·c++·学习
额呃呃5 小时前
leetCode第33题
数据结构·算法·leetcode
dragoooon345 小时前
[优选算法专题四.前缀和——NO.27 寻找数组的中心下标]
数据结构·算法·leetcode
少许极端5 小时前
算法奇妙屋(七)-字符串操作
java·开发语言·数据结构·算法·字符串操作
小龙报5 小时前
《算法通关指南---C++编程篇(2)》
c语言·开发语言·数据结构·c++·程序人生·算法·学习方法
liu****8 小时前
10.queue的模拟实现
开发语言·数据结构·c++·算法
shinelord明8 小时前
【大数据技术实战】Kafka 认证机制全解析
大数据·数据结构·分布式·架构·kafka
让我们一起加油好吗9 小时前
【基础算法】01BFS
数据结构·c++·算法·bfs·01bfs