顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
Pluchon5 分钟前
硅基计划6.0 柒 JavaEE 浅谈JVM&GC垃圾回收
java·jvm·数据结构·java-ee·gc
不穿格子的程序员37 分钟前
从零开始刷算法——二分-搜索旋转排序数组
数据结构·算法
sin_hielo2 小时前
leetcode 2536
数据结构·算法·leetcode
what_20182 小时前
list集合使用
数据结构·算法·list
im_AMBER4 小时前
数据结构 11 图
数据结构·笔记·学习·图论
xiaoye-duck5 小时前
数据结构之二叉树-链式结构(上)
数据结构
Doro再努力5 小时前
2025_11_14洛谷【入门1】数据结构刷题小结
前端·数据结构·算法
cs麦子5 小时前
C语言--详解--指针--下
c语言·数据结构·算法
flashlight_hi5 小时前
LeetCode 分类刷题:3217. 从链表中移除在数组中存在的节点
javascript·数据结构·leetcode·链表
oioihoii6 小时前
C++中有双向映射数据结构吗?Key和Value能否双向查找?
数据结构·c++·算法