#include
#define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0
#define INFEASIBLE -1 #define OVERFLOW -2 typedef int Status;
typedef struct { char sno[4]; char sname[10]; int sage; char sdept[3]; }StuType;
typedef StuType ElemType;
void main() { List L; ElemType stu,stu_tmp; int func,pos; if (!InitList(L)) { printf(\ exit(-1); } for (int j=0;;j++) { printf(\select the function:\\n0--Exit\\n1--insert student\\n2--delete student\\n3--update student name\\n4--search student with sno\\n5--show all student\\n6--count the student\\n Please input:\ scanf(\ switch (func) { case 0: exit(1);
break;
case 1: //插入学生信息 printf(\ scanf(\ printf(\ scanf(\ printf(\ scanf(\ printf(\ scanf(\ ListInsert(L,ListLength(L)+1,stu); break;
case 2://删除指定学号的学生信息 printf(\ scanf(\ pos=LocateElem(L,stu,equal); if (pos>0) ListDelete(L,pos,stu); else printf(\ break;
case 3://更新指定学号的学生姓名 printf(\ scanf(\ pos=LocateElem(L,stu,equal); if (pos>0) { printf(\ scanf(\ GetElem(L,pos,stu_tmp); stu.sage=stu_tmp.sage; strcpy(stu.sdept,stu_tmp.sdept); PutElem(L,pos,stu); } else printf(\ break;
case 4://查找指定学号的学生信息 printf(\ scanf(\ pos=LocateElem(L,stu,equal); if (pos>0) { GetElem(L,pos,stu_tmp);
}
printf(\ } else printf(\ break; case 5: //输出所有学生信息 ListTraverse(L,visit); break; }
case 6: //输出学生数量 printf(\ListLength(L)); break; }