顺序表的创建

数据结构脑图:

数据结构脑图(部分)

创建一个顺序表:

seqList.h

#ifndef SEQLIST_H

#define SEQLIST_H

/*

struct sequence seqList{

int data30;

int len;

};

*/

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#define MAX 30

typedef int Datatype;

typedef struct sequence

{

Datatype dataMAX;

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 小时前
2026萌新联赛第三场-- (郑州轻工业大学)
数据结构·c++·经验分享·算法·贪心算法·排序算法·深度优先
冻柠檬飞冰走茶7 小时前
PTA基础编程题目集 7-8超速判断(C++语言实现)
开发语言·数据结构·c++·算法
2501_942389558 小时前
Epoch AI旗下FrontierMath的负责人Elliot Glazer
数据结构·决策树·动态规划·散列表
shylyly_9 小时前
104.二叉树的最大深度
数据结构·算法·104.二叉树的最大深度
白白白小纯13 小时前
每日算法day3—回文链表,链表分割
c语言·数据结构·算法·leetcode
zander25815 小时前
35. 搜索插入位置:从边界语义理解二分查找
数据结构·算法·leetcode
Chen—LSN15 小时前
C语言——深度理解指针(5)
c语言·数据结构·算法·排序算法
佳児素花痴╮17 小时前
树的基础知识与查找排序算法
数据结构·算法
郝学胜-神的一滴18 小时前
Python 高级编程 026:内置数据结构之骈文纵论
开发语言·数据结构·python·程序人生·软件工程
程序员老舅1 天前
啃透 I2C 驱动开发,才算入门嵌入式 Linux 内核驱动
数据结构·驱动开发·b树·内核·嵌入式·嵌入式开发·i2c