• 大小: 5KB
    文件类型: .cpp
    金币: 1
    下载: 0 次
    发布日期: 2021-01-04
  • 语言: C/C++
  • 标签: 顺序表  

资源简介

数据结构课程设计作业 基于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-

评论

共有 条评论