我这个顺序表为啥全是0咧,还有这个删除为啥感觉没用咧
#include<stdio.h>#include<stdlib.h>#define maxsize 30typedef struct{int date[maxsize];int length;} seqlist;void initList(seqlist&L){ for(int i=0;i<maxsize;i++){L.date[i]=0;L.length=0; }}bool ListInsert(seqlist&L ,int i ,int e){if(i<1||i>L.length+1);return false;if(L.length>maxsize);return false;for(int j=L.length;j>=i;j--){L.date[j]=L.date[j-1];}L.date[i-1]=e;L.length++;return true;}bool Listdelete(seqlist&L,int i,int &e){ if(i<1||i>L.length+1);return false;if(L.length>maxsize);return false;e=L.date[i-1];for(int j;j>i;j++){L.date[j-1]=L.date[j];}L.length--;return true;}int main(){seqlist L;initList(L);for(int i=0;i<maxsize;i++){ListInsert(L,i+1,i+2);}for(int i=0;i<maxsize;i++) {printf("%d",L.date[i]);}printf("\n");int e;Listdelete(L,3,e);printf("%d",e);return 0;}
#include<stdio.h>#include<stdlib.h>#define maxsize 30typedef struct{int date[maxsize];int length;} seqlist;void initList(seqlist&L){ for(int i=0;i<maxsize;i++){L.date[i]=0;L.length=0; }}bool ListInsert(seqlist&L ,int i ,int e){if(i<1||i>L.length+1);return false;if(L.length>maxsize);return false;for(int j=L.length;j>=i;j--){L.date[j]=L.date[j-1];}L.date[i-1]=e;L.length++;return true;}bool Listdelete(seqlist&L,int i,int &e){ if(i<1||i>L.length+1);return false;if(L.length>maxsize);return false;e=L.date[i-1];for(int j;j>i;j++){L.date[j-1]=L.date[j];}L.length--;return true;}int main(){seqlist L;initList(L);for(int i=0;i<maxsize;i++){ListInsert(L,i+1,i+2);}for(int i=0;i<maxsize;i++) {printf("%d",L.date[i]);}printf("\n");int e;Listdelete(L,3,e);printf("%d",e);return 0;}