顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

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;
}
相关推荐
星星火柴93617 分钟前
数据结构:链表 (C++实现)
数据结构·c++·笔记·链表
在努力的韩小豪21 分钟前
B树和B+树的区别(B Tree & B+ Tree)
数据结构·数据库·b树·b+树·索引·数据库索引
ん贤35 分钟前
2024第十五届蓝桥杯大赛软件赛省赛C/C++ 大学 B 组
c语言·数据结构·c++·经验分享·笔记·算法·蓝桥杯
Phoebe鑫2 小时前
数据结构每日一题day11(链表)★★★★★
数据结构·算法
Jay_See2 小时前
Leetcode——239. 滑动窗口最大值
java·数据结构·算法·leetcode
什码情况2 小时前
微服务集成测试 -华为OD机试真题(A卷、JavaScript)
javascript·数据结构·算法·华为od·机试
洋次郎的歌3 小时前
我要成为数据结构与算法高手(三)之双向循环链表
数据结构
我不会编程5551 天前
Python Cookbook-5.1 对字典排序
开发语言·数据结构·python
owde1 天前
顺序容器 -list双向链表
数据结构·c++·链表·list
第404块砖头1 天前
分享宝藏之List转Markdown
数据结构·list