#include #include #define initsize 10
typedef structseqlist;
void initdata(seqlist&); //初始化順序表
void increasesize(seqlist & , int); //增加順序表長度
void insertdata(seqlist & , int , int); //插入資料
int deletedata(seqlist & , int , int &); //刪除資料
int searchdata(seqlist , int); //按位查詢資料
int searchnum(seqlist , int); //按值查詢資料
int main(void)
printf("\n");
int e = -1;
printf("刪除的資料是:%d",deletedata(line,2,e)); //刪除資料
printf("\n");
printf("當前順序表中的資料是:"); //列印順序表中資料
for(int i = 0 ; i < line.length ; i ++)
printf("\n");
printf("查詢的資料是:%d",searchdata(line,2));
printf("\n");
printf("查詢的值在第%d位。",searchnum(line,4));
return 0;
}//初始化
void initdata(seqlist &l)
}//增加順序表長度
void increasesize(seqlist &l , int len)
l.maxsize = l.maxsize + len;
free(p);
}//插入資料
void insertdata(seqlist &l , int m , int n)
l.data[m-1] = n;
l.length ++;
} //刪除資料
int deletedata(seqlist &l , int m , int &n)
l.length --;
return n;
}//按位查詢
int searchdata(seqlist l , int m)
//按數值查詢
int searchnum(seqlist l , int n)
} return -1;
}
動態順序表的基本操作
seqlistd.h pragma once include include include typedef int datatype typedef struct seqlistd seqlistd,pseqlistd void seqlistdinit pseqlistd ps,int capa...
動態順序表
ifndef seqlist h define seqlist h define capacity 3 typedef struct seqlist typedef enum tag typedef struct findret void expendseqlist seqlist pseq 擴大容...
動態順序表
動態順序表 引用庫函式 include include 巨集定義 define list init size 4 define list add size 2 define overflow 2 typedef int elemtype elemtype元素型別 定義結構體 typedef stru...