顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
hh随便起个名32 分钟前
力扣二叉树的三种遍历
javascript·数据结构·算法·leetcode
xie_pin_an2 小时前
深入浅出 C 语言数据结构:从线性表到二叉树的实战指南
c语言·数据结构·图论
tang&3 小时前
滑动窗口:双指针的优雅舞步,征服连续区间问题的利器
数据结构·算法·哈希算法·滑动窗口
Nandeska4 小时前
2、数据库的索引与底层数据结构
数据结构·数据库
又是忙碌的一天5 小时前
二叉树的构建与增删改查(2) 删除节点
数据结构
Code Slacker6 小时前
LeetCode Hot100 —— 滑动窗口(面试纯背版)(四)
数据结构·c++·算法·leetcode
F_D_Z7 小时前
最长连续序列(Longest Consecutive Sequence)
数据结构·算法·leetcode
WolfGang0073217 小时前
代码随想录算法训练营Day50 | 拓扑排序、dijkstra(朴素版)
数据结构·算法
一直都在5727 小时前
数据结构入门:二叉排序树的删除算法
数据结构·算法
hweiyu008 小时前
排序算法简介及分类
数据结构