資源簡介
數據結構課程設計作業
基于vc++6.0
順序表的基本操作
附有注釋
代碼片段和文件信息
#include?
#include?
#include?//庫函數
#define?MAXSIZE?100
typedef?int?DataType;
typedef?struct
{
DataType?elem[MAXSIZE];
int?length;
}SeqList;
????/*順序表初始化函數*/
int?InitSeqList(SeqList?*&L)
{
L=(SeqList?*)malloc(sizeof(SeqList));
if(!L)
{
printf(“\t\t\t內存分配錯誤\n“);
return?0;
}
else
{
L->length=0;
printf(“\t\t\t內存分配成功\n“);
return?1;
}
}
???/*插入函數*/
int?InsertSeqList(SeqList?*Lint?iDataType?x)
{
int?j;
if(L->length==MAXSIZE)???????????
{
printf(“\t\t\t順序表已滿!\n“);
return?0;
}
else
{
if(i<1||i>L->length+1)
{?
printf(“\t\t\t位置不合法!“);
return?0;
??}
else
{?
i--;
for(j=L->length-1;j>=i;j--)?????
{
L->elem[j+1]=L->elem[j];
}
L->elem[i]=x;
????????????L-
- 上一篇:棋盤格 標定板制作Opencv程序
- 下一篇:遺傳算法c++實現模板
評論
共有 條評論