顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
Fanxt_Ja14 小时前
【LeetCode】算法详解#15 ---环形链表II
数据结构·算法·leetcode·链表
今后12316 小时前
【数据结构】二叉树的概念
数据结构·二叉树
散1121 天前
01数据结构-01背包问题
数据结构
消失的旧时光-19431 天前
Kotlinx.serialization 使用讲解
android·数据结构·android jetpack
Gu_shiwww1 天前
数据结构8——双向链表
c语言·数据结构·python·链表·小白初步
苏小瀚1 天前
[数据结构] 排序
数据结构
睡不醒的kun1 天前
leetcode算法刷题的第三十四天
数据结构·c++·算法·leetcode·职场和发展·贪心算法·动态规划
吃着火锅x唱着歌1 天前
LeetCode 978.最长湍流子数组
数据结构·算法·leetcode
Whisper_long1 天前
【数据结构】深入理解堆:概念、应用与实现
数据结构
IAtlantiscsdn1 天前
Redis7底层数据结构解析
前端·数据结构·bootstrap