#ifndef _Vector_H
#include<stdlib.h>
#include<stdio.h>
enum boolean{
FALSE,TRUE};
#define ElementType int
typedef enum boolean Bool;
struct vector{
ElementType * elements;
int ArraySize;
int VectorLength;
};
typedef struct vector Vector;
void GetArray(Vector *);
void InitVector(Vector *,int az);
ElementType GetNode(Vector * V, int t);
void FreeVector(Vector *);
int Find(Vector *,ElementType);
Bool Remove(Vector *,int i);
void GetArray(Vector * V){
V->elements=(ElementType *)malloc(sizeof(ElementType)*V->ArraySize);
if(!V->elements)
printf("Memory Allocation Error!\n");
}
void InitVector(Vector * V, int sz){
//初始化函数,建立一个最大长度为sz的数组
if(sz<=0)
printf("Invalid Array Size\n");
else{
V->ArraySize=sz;
V->VectorLength=0;
GetArray(V
向量(熊岳山-数据结构与算法)
最新推荐文章于 2020-12-20 15:41:28 发布