}
void delNode(sequenlist *L) {
int i,j;
printf(\请先查找您要删除的学生信息:\\n\ i=findList(L); if(i==-1) {
printf(\没有查到要删除的学生信息\ return; }
for(j=i;j
L->stu[j].score=L->stu[j+1].score;
strcpy(L->stu[j].num,L->stu[j+1].num); strcpy(L->stu[j].name,L->stu[j+1].name);
strcpy(L->stu[j].gender,L->stu[j+1].gender); }
L->length--;
printf(\该学生信息已被删除!\\n\}
void main() {
sequenlist *L;
DataType *student; int i;
L=(sequenlist *)malloc(sizeof(sequenlist)); while(1){
switch(menu_select()) {
case 1:
printf(\ printf(\学生信息线性表的建立 \\n\ printf(\ createList(L); break; case 2:
printf(\ printf(\添加学生信息\\n\
printf(\请输入要添加的学生信息:\\n\
printf(\学号(8) 姓名(8) 性别 成绩\\n\
printf(\
- 5 -
student=(DataType *)malloc(sizeof(DataType)); fflush(stdin);
scanf(\re);
printf(\请输入要插入的位置:\\n\ fflush(stdin); scanf(\
insert(L,student,i); break; case 3:
printf(\ printf(\查询学生信息\\n\
printf(\ i=findList(L); if(i!=-1) {
printf(\您要查的学生为:\\n学号(8) 姓名(8) 性别 成绩\\n\ printf(\
printf(\tu[i].score);
printf(\-\\n\
} else
printf(\没有您要查询的学生信息!\ break; case 4:
printf(\ printf(\删除学生信息\\n\
printf(\ delNode(L); break; case 5:
printf(\ printf(\输出所有学生信息\\n\
printf(\ printList(L); break; case 0:
printf(\再见!\\n\ getch();
- 6 -
return; } } }
四、实验结果
1.学生信息线性表的建立
2.插 入 学 生 信 息
- 7 -
3.查 询 学 生 信 息
4.删 除 学 生 信 息
- 8 -
5.输 出 所有学生信息
0.退 出 管 理 系 统
- 9 -