顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
蚊子码农7 小时前
算法题解记录--239滑动窗口最大值
数据结构·算法
额,不知道写啥。9 小时前
HAO的线段树(中(上))
数据结构·c++·算法
blackicexs9 小时前
第五周第七天
数据结构·算法
夏乌_Wx10 小时前
反转链表:三种实现思路与细节梳理
数据结构·链表
紫陌涵光11 小时前
108.将有序数组转换为二叉搜索树
数据结构·算法·leetcode
载数而行52012 小时前
算法系列2之最短路径
c语言·数据结构·c++·算法·贪心算法
fu的博客12 小时前
【数据结构10】满/完全二叉树、顺序/链式存储
数据结构·
逆境不可逃13 小时前
【除夕篇】LeetCode 热题 100 之 189.轮转数组
java·数据结构·算法·链表
wefg113 小时前
【算法】倍增思想(快速幂)
数据结构·c++·算法
Zik----13 小时前
Leetcode24 —— 两两交换链表中的节点(迭代法)
数据结构·算法·链表