华中科技大学计算机 学院课程实验报告 L1.elem=L2.elem=NULL; //status j; /*
L1.elem=(Elemtype *) malloc(sizeof(Elemtype)*10); L1.length=4;
L1.elem[0].item1=1; L1.elem[1].item1=2; L1.elem[2].item1=3; L1.elem[3].item1=4; */
printf(\ i=-1;
scanf(\ while(i!=1&&i!=0) {
printf(\ scanf(\ }
if(i)
LoadList(&L1,&L2); getchar();getchar(); do{
system(\ menu();
printf(\ scanf(\ while(op>12||op<0) {
printf(\input the correct option number again: \ scanf(\ }
switch(op){
case 0: break; case 1: {
printf(\being realized\\n\
jud1=InitList(&L1); jud2=InitList(&L2); getchar();getchar(); if(jud1==1)
printf(\ InitList L1
8
华中科技大学计算机 学院课程实验报告 successfully!\\n\
else
printf(\ if(jud2==1)
printf(\ InitList L2 successfully!\\n\
else
printf(\ getchar();getchar(); }
case 2: {
printf(\being realized\\n\
jud1=DestroyList(&L1); jud2=DestroyList(&L2); getchar();getchar(); if(jud1==1)
printf(\successfully!\\n\
else
printf(\exists!\\n\
if(jud2==1)
printf(\successfully!\\n\
else
printf(\exists!\\n\
}
case 3: {
printf(\being realized\\n\
jud1=ClearList(&L1); jud2=ClearList(&L2); getchar();getchar(); if(jud1==1)
printf(\successfully!\\n\
else
printf(\ if(jud2==1)
Destroy L1 Destroy L2 Clear L1 9
break; getchar();getchar(); break; 华中科技大学计算机 学院课程实验报告 printf(\ Clear L2 successfully!\\n\
else
printf(\ getchar();getchar(); break; }
case 4: {
printf(\being realized\\n\
getchar();getchar(); if(L1.elem == NULL)
printf(\exists!\\n\
else {
jud1=ListEmpty(L1); if(jud1==1)
printf(\ else
printf(\ }
if(L2.elem == NULL)
printf(\exists!\\n\
else {
jud2=ListEmpty(L2); if(jud2==1)
printf(\ else
printf(\ }
}
case 5: {
printf(\being realized\\n\
jud1=ListLength(L1); jud2=ListLength(L2); getchar();getchar(); if(L1.elem==NULL)
printf(\
10
getchar();getchar(); break; 华中科技大学计算机 学院课程实验报告 else
printf(\ the length of L1 is %d\\n\
if(L2.elem==NULL)
printf(\ else
printf(\ the length of L2 is %d\\n\
getchar();getchar(); break; }
case 6: {
printf(\ here is GetElem(),which being realized\\n\
printf(\ please input the which number of you want to get: \
scanf(\
jud1=GetElem(L1,i,pe1); jud2=GetElem(L2,i,pe2); if(jud1==1)
printf(\ find it in L1, it is %d!\\n\
else
printf(\ if(jud2==1)
printf(\ find it in L2, it is %d!\\n\
else
printf(\ getchar();getchar(); break; }
case 7: {
printf(\being realized\\n\
printf(\the element you want to search: \
scanf(\ if(L1.elem == NULL)
printf(\ else {
jud1 = LocatElem(L1,a,&equal); if(jud1)
11
华中科技大学计算机 学院课程实验报告 printf(\ the element you find locates No.%d in L1\\n\
else
printf(\found!\\n\
}
if(L2.elem == NULL)
printf(\ else {
jud2 = LocatElem(L2,a,&equal); if(jud2)
printf(\ the element you find locates No.%d in L2\\n\
else
printf(\found!\\n\
}
getchar();getchar(); break; }
case 8: {
printf(\being realized\\n\
printf(\list you want to use?\\n 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 prior: \
scanf(\ jud1=PriorElem(L1,a,&e1); if(jud1==1)
{printf(\it is\\n\
else
printf(\find it!\\n\
12