数据结构脑图:
数据结构脑图(部分)
创建一个顺序表:
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;
}