顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
不知名的老吴1 天前
案例教学:最长递增子序列问题
数据结构·算法·动态规划
_小草鱼_1 天前
【数据结构】栈和队列
数据结构·数组··队列
贾斯汀玛尔斯1 天前
每天学一个算法--图算法(Graph Algorithms)
数据结构·算法
网安INF1 天前
数据结构第四章复习:树与二叉树
数据结构
我是无敌小恐龙1 天前
Java SE 零基础入门 Day02 运算符与流程控制超详细笔记
java·数据结构·spring boot·笔记·python·spring·spring cloud
念越1 天前
算法每日一题 Day04|快慢双指针法解决环形链表问题
数据结构·算法·链表
求学的小高1 天前
数据结构Day6(普通树、森林与二叉树的关系、哈夫曼编码、并查集)
数据结构·笔记·考研
算法鑫探1 天前
贪心算法(C 语言实现)及经典应用
c语言·数据结构·算法·贪心算法
Peregrine91 天前
数据结构 - > 双链表
c语言·数据结构·算法
qeen871 天前
【数据结构】队列及其C语言模拟实现
c语言·数据结构·c++·学习·队列