顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
handler012 分钟前
进程状态流转的本质:Linux 内核队列与底层数据结构解密
linux·运维·c语言·数据结构·c++·笔记·学习
自我意识的多元宇宙12 分钟前
数据结构--散列函数的构造方法
数据结构
如君愿14 分钟前
考研复习 Day 25 | 习题--计算机网络第三章(数据链路层 上)、数据结构(串)
数据结构·计算机网络·考研
夏末蝉未鸣0115 分钟前
Sort-Merge Join【排序连接算法】详解(python代码实现,以FULL JOIN为例)
数据结构·算法
_日拱一卒23 分钟前
LeetCode:23合并K个升序链表
java·数据结构·算法·leetcode·链表·职场和发展
求学的小高2 小时前
数据结构Day10(ASL、二分查找、分块查找)
数据结构·笔记·考研
算法鑫探2 小时前
算法与数据结构 以及算法复杂度
c语言·数据结构·算法·新人首发
迷途之人不知返2 小时前
List的学习
数据结构·c++·学习·list
啊哦呃咦唔鱼3 小时前
Leetcodehot100-215. 数组中的第K个最大元素
数据结构·算法·leetcode
苏渡苇3 小时前
Redis 核心数据结构(二)——List 与消息队列
数据结构·redis·list·redis发布订阅