早教吧 育儿知识 作业答案 考试题库 百科 知识分享

数据结构的一个小题目,下面的程序有错误,请帮改正#defineMAXSIZE100/*宏定义*/#defineOK1#defineOVERFLOW-2#include"stdio.h"/*包含输入输出文件*/typedefintelemtype;typedefstruct/*定义顺序表的结

题目详情
数据结构的一个小题目 ,下面的程序有错误,请帮改正#define MAXSIZE 100 /*宏定义*/ #define OK 1 #define OVERFLOW -2 #include "stdio.h" /*包含输入输出文件*/ typedef int elemtype; typedef struct /*定义顺序表的结构*/ {elemtype vec[MAXSIZE]; /*顺序表数据成员所占据的存储空间*/ int last; /*顺序表中最后一个元素在数组中的下标(或向量中的位置)从0开始*/ }sequenlist; int insert(L,i,x) /*在顺序表的第i个元素之前插入一个新元素x*/ sequenlist *L; int i; elemtype x; { int j; if(((*L).last)>=MAXSIZE-1) {printf("the list is overflow!\n"); return(0); /*溢出判断*/ } else if((i(*L).last+1)) {printf("position is not correct!\n"); return(0); /*插入位置不正确*/ } else {for(j=(*L).last;j>=i-1;j--) /*后移元素*/ (*L).vec[j+1]=(*L).vec[j]; (*L).vec[i-1]=x; /*插入新元素*/ (*L).last=(*L).last+1;/*修改last的值*/ } return(1); } void delete(L,i) /*删除顺序表的第i个元素*/ sequenlist *L; int i; { int j; if((i(*L).last+1)) printf("delete fail\n"); else {for(j=i;j
▼优质解答
答案和解析
#define maxsize 100; 这句的;去掉,宏定义不用接;