|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 5
typedef int ElemType;
typedef struct{
ElemType *elem;
int length;
}SqList;
void InitList(SqList &L);[b]/*您需要编写的代码*/
int ListDelete(SqList &L,int i);
int main()
{
SqList L;
InitList(L);
int i;
scanf("%d",&i);
int result=ListDelete(L,i);
if(result==0){
printf("Delete Error.The value of i is illegal!");
}else if(result==1){
printf("Delete Success.The elements of the SequenceList L are:");
for(int j=0;j<L.length;j++){
printf(" %d",L.elem[j]);
}
}
return 0;
}
int ListDelete(SqList &L,int i){
int j;
if(i > L.length || i < 1)
return 0;
for(j = i-1;j < L.length ;j++){
L.elem[j] = L.elem[j+1];
}
L.length--;
return 1;
}
/* 请在这里填写答案 */ |
评分
-
查看全部评分
|