求助大神!线性表调用插入、删除等子函数的C语言主函数(用switch函数)怎么写?

以下是大致框架:
#include
#include

#define LIST_INIT_SIZE 100
#define LISTINCREAMENT 10
#define ERROR 0
#define OK 1
#define OVERFLOW 0

typedef int ElemType;
typedef int Status;

typedef struct
{
ElemType *elem; // 线性表占用的数组空间
int length; //线性表的长度
int listsize; //当前分配的存储容量(以sizeof(ElemType)为单位)
} SeqList;

/*=============================================*/
Status InitList_Sq(SeqList *L);
Status ListInsert_Sq(SeqList *L, int i, ElemType e);
Status ListDelete_Sq(SeqList *L, int i, ElemType *e);
int LocateElem_Sq(SeqList L, ElemType e);
void MergeList(SeqList La, SeqList Lb, SeqList *Lc);
void printList(SeqList *L);

/*=================main===========================*/
void main()
{

SeqList *La;
{
InitList_Sq(La);
printf("线性表Sqlist初始化成功!\n");
}

int i, e;
int a[6] = {1,3,5,7,9,11};
for(i=0; i<6; i++)
{
ListInsert_Sq(La, i+1, a[i]);
}

printList(La);
ListDelete_Sq(La, 3, &e);
printList(La);
LocateElem_Sq(La, 13);

.......
while(1)
{
printf("pleases input the operate code: 0/insert, 1/delete, 2/locate, 3/merge");
int opcode;
scanf("%d", &opcode);

    switch(opcode)
    {
    case 0:
        ListInsert_Sq(La, .....);
        break;
    case 1:
        ListDelete_Sq(La,..);
        break;
    case 2:
        LocateElem_Sq(La,);
        break;
    case 3:
        MergeList(La,);
        break;
    default:
        InitList_Sq(La,)
    }
}

}

//================子函数======================
Status InitList_Sq(SeqList *L)
{
}

Status ListInsert_Sq(SeqList *L, int i, ElemType e)

Status ListDelete_Sq(SeqList *L, int i, ElemType *e)

int LocateElem_Sq(SeqList L, ElemType e)

void MergeList(SeqList La, SeqList Lb, SeqList *Lc)

void printList(SeqList *L)

2个回答

无非就是函数名不同,上面的代码你参考下。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐