华中科技大学计算机 学院课程实验报告 }
else if(i==2&&L2.elem!=NULL) {
printf(\ Input which element you want find its prior: \
scanf(\ jud2=PriorElem(L2,a,&e2); if(jud2==1)
{printf(\ Find the prior, it is\\n\
else
printf(\ Not find it!\\n\
} else
printf(\not existed!\\n\
getchar();getchar(); break; }
case 9: {
printf(\ here is NextElem(),which being realized\\n\
printf(\L1 or L2(Input 1 or 2): \
scanf(\ while(i!=1&&i!=2) {
printf(\\
scanf(\ }
if(i==1&&L1.elem!=NULL) {
printf(\want find its next: \
scanf(\ jud1=NextElem(L1,a,&e1); if(jud1==1)
{printf(\the next, it is\\n\
else
printf(\find it!\\n\ }
13
华中科技大学计算机 学院课程实验报告 else if(i==2&&L2.elem!=NULL) {
printf(\ Input which element you want find its next: \
scanf(\ jud2=NextElem(L2,a,&e2); if(jud2==1)
{printf(\ Find the next, it is\\n\
else
printf(\ Not find it!\\n\
} else
printf(\not existed!\\n\
getchar();getchar(); break; }
case 10: {
printf(\ here is ListInsert(),which being realized\\n\ i=-1;
printf(\ Which list you want to insert?\\n L1 or L2(Input 1 or 2): \ scanf(\ while(i!=1&&i!=2) {
printf(\\
scanf(\ }
if(i==1&&L1.elem!=NULL) {
printf(\the element you want to insert: \
scanf(\
printf(\ Input the location you want to insert: \
scanf(\
jud1=ListInsert(&L1,i,a); if(jud1)
printf(\ Insert successfully!\\n\
14
华中科技大学计算机 学院课程实验报告 else
printf(\ }
else if(i==2&&L2.elem!=NULL) {
printf(\the element you want to insert: \
scanf(\
printf(\ Input the location you want to insert: \
scanf(\
jud2=ListInsert(&L2,i,a); if(jud2)
printf(\ Insert successfully!\\n\
else
printf(\ } else
printf(\not existed!\\n\
getchar();getchar(); break; }
case 11: {
printf(\ here is ListDelete(),which being realized\\n\ i=-1;
printf(\ Which list you want to delete?\\n L1 or L2(Input 1 or 2): \ scanf(\ while(i!=1&&i!=2) {
printf(\\
scanf(\ }
if(i==1&&L1.elem!=NULL) {
printf(\ Input the location you want to delete: \
scanf(\
jud1=ListDelete(&L1,i,&a); if(jud1)
15
华中科技大学计算机 学院课程实验报告 printf(\ Insert successfully! The element that was deleted is %d\\n\ else
printf(\ }
else if(i==2&&L2.elem!=NULL) {
printf(\ Input the location you want to insert: \
scanf(\
jud2=ListDelete(&L2,i,&a); if(jud2)
printf(\ Insert successfully! The element that was deleted is %d\\n\ else
printf(\ } else
printf(\not existed!\\n\
getchar();getchar(); break; }
case 12: {
printf(\ here is ListTrabverse(),which being realized\\n\
char tablename[9]; do{
printf(\table name[L1,L2]: \
scanf(\ }while(strcmp(tablename,\&& strcmp(tablename,\
if(!strcmp(tablename,\ if(!L1.elem)
printf(\does not exist!\\n\
else if(!ListTrabverse(L1,display))
printf(\ this liear table is empty!\\n\ }
16
华中科技大学计算机 学院课程实验报告 if(!strcmp(tablename,\ if(!L2.elem)
printf(\does not exist!\\n\
else if(!ListTrabverse(L2,display))
printf(\ this liear table is empty!\\n\ }
getchar();getchar(); break; } default: ; } }
while(op);
printf(\again!--------------------\\n\ SaveListToFile(&L1,&L2); getchar();getchar(); return 0; }
status InitList(SqList * L){
L->elem = (Elemtype *)malloc(LIST_INIT_SIZE*sizeof(Elemtype)); if(!L->elem)
return OVERFLOW; L->length=0;
L->listsize=LIST_INIT_SIZE; return OK; }
status DestroyList(SqList * L){ if(L->elem == NULL) return ERROR; else {
free(L->elem); L->elem = NULL; return OK; } }
17