顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
㓗冽5 小时前
8皇后·改-进阶题16
数据结构
月落归舟7 小时前
帮你从算法的角度来认识数组------( 二 )
数据结构·算法·数组
Wave8459 小时前
数据结构—树
数据结构
ic爱吃蓝莓9 小时前
数据结构 | HashMap原理
数据结构·学习·算法·链表·哈希算法
liuyao_xianhui11 小时前
优选算法_分治_快速排序_归并排序_C++
开发语言·数据结构·c++·算法·leetcode·排序算法·动态规划
CryptoPP11 小时前
开发者指南:构建实时期货黄金数据监控系统
大数据·数据结构·笔记·金融·区块链
月落归舟12 小时前
每日算法题 14---14.环形链表
数据结构·算法·链表
光电笑映13 小时前
STL 源码解剖系列:map/set 的底层复用与红黑树封装
c语言·数据结构·c++·算法
沉鱼.4413 小时前
滑动窗口问题
数据结构·算法
ysa05103013 小时前
二分+前缀(预处理神力2)
数据结构·c++·笔记·算法