顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
菜择贰17 小时前
B树的性质和查找、插入、删除操作
数据结构·b树
LDR00618 小时前
接口焦虑终结者:LDR6020 芯片如何重新定义 Type-C 拓展坞与多设备互联时代
数据结构·经验分享·智能音箱
_深海凉_19 小时前
LeetCode热题100-最小栈
java·数据结构·leetcode
_深海凉_20 小时前
LeetCode热题100-除了自身以外数组的乘积
数据结构·算法·leetcode
xiaotao13121 小时前
01-编程基础与数学基石: Python核心数据结构完全指南
数据结构·人工智能·windows·python
浅念-1 天前
从LeetCode入门位运算:常见技巧与实战题目全解析
数据结构·数据库·c++·笔记·算法·leetcode·牛客
剑挑星河月1 天前
763.划分字母区间
数据结构·算法·leetcode
iiiiyu1 天前
面向对象高级接口的综合案例
java·开发语言·数据结构·编程语言
Mem0rin1 天前
[Java/数据结构]二叉树练习题几则
java·开发语言·数据结构
北顾笙9801 天前
day24-数据结构力扣
数据结构·算法·leetcode