顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
paeamecium10 小时前
【PAT甲级真题】- Student List for Course (25)
数据结构·c++·算法·list·pat考试
Book思议-10 小时前
【数据结构】栈与队列全方位对比 + C 语言完整实现
c语言·数据结构·算法··队列
是苏浙11 小时前
初识集合框架
java·数据结构
如何原谅奋力过但无声12 小时前
【chap11-动态规划(上 - 基础题目&背包问题)】用Python3刷《代码随想录》
数据结构·python·算法·动态规划
小王C语言13 小时前
【基础IO】————简单设计一下libc库
前端·数据结构·算法
_日拱一卒14 小时前
LeetCode:滑动窗口的最大值
数据结构·算法·leetcode
老约家的可汗14 小时前
list 容器详解:基本介绍与常见使用
c语言·数据结构·c++·list
Book思议-14 小时前
【数据结构】字符串模式匹配:暴力算法与 KMP 算法实现与解析
数据结构·算法·kmp算法·bf算法
mifengxing15 小时前
力扣HOT100——(1)两数之和
java·数据结构·算法·leetcode·hot100
罗湖老棍子15 小时前
【 例 1】区间和(信息学奥赛一本通- P1547)(基础线段树和单点修改区间查询树状数组模版)
数据结构·算法·线段树·树状数组·单点修改 区间查询