顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

seqList.h

#ifndef SEQLIST_H

#define SEQLIST_H

/*

struct sequence seqList{

int data30;

int len;

};

*/

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#define MAX 30

typedef int Datatype;

typedef struct sequence

{

Datatype dataMAX;

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;
}
相关推荐
疯狂打码的少年4 小时前
【数据结构】图的存储结构:邻接矩阵与邻接表
数据结构·笔记
203号居民5 小时前
LeetCode hot 100 —41. 缺失的第一个正数
数据结构·算法·leetcode
2401_862880828 小时前
数据结构 --- 栈
c语言·数据结构·算法
额额额对了10 小时前
数据结构:二叉树
c语言·数据结构·算法
qeen8710 小时前
【数据结构】红黑树的算法原理解析与实现
开发语言·数据结构·c++·算法·红黑树
m0_5474866611 小时前
《数据结构与算法(Python语言版)》全套PPT课件2026
数据结构·算法
hold?fish:palm12 小时前
27 合并两个有序链表
数据结构·链表
个 人 练 习 生12 小时前
数据结构入门:算法复杂度
开发语言·数据结构·经验分享·学习·程序人生·算法
月华路13 小时前
Guava 图数据结构 graph 从基础概念到原理分析
java·数据结构·guava·图搜索
Herbert_hwt14 小时前
第九章 Java异常及程序调试技术
java·开发语言·数据结构