go语言学生管理练习题 go语言学生管理系统( 五 )


for(i=0;i80;i++)
printf("*");
printf("1按学生学号排序\t2按学生姓名排序\t3按计算机 成绩排序\n");
printf("4按英语成绩排序\t5按数学成绩排序\t\n");
for(i=0;i80;i++)
printf("*");
printf("请选择操作:");
scanf("%d",x);/*选择操作*/
getchar();
switch(x)
{case 1 :
for(i=1;in;i++)
{
for(j=i+1;j=n;j++)
{
max=p;
p=p-next;
if(max-numberp-number)
{
k=max-number;
max-number=p-number;
p-number=k;
strcpy(t,max-name);
strcpy(max-name,p-name);
strcpy(p-name,t);
fen=max-computer;
max-computer=p-computer;
p-computer=fen;
fen=max-english;
max-english=p-english;
p-english=fen;
fen=max-math;
max-math=p-math;
p-math=fen;
}
}
max=head;p=head;/*重新使max,p指向链表头*/
}
print(head);break;
case 2 :for(i=1;in;i++)
{
for(j=i+1;j=n;j++)
{
max=p;
p=p-next;
if(strcmp(max-name,p-name)0)/*字符串比较*/
{
strcpy(t,max-name);/*字符串复制*/
strcpy(max-name,p-name);
strcpy(p-name,t);
k=max-number;
max-number=p-number;
p-number=k;
fen=max-computer;
max-computer=p-computer;
p-computer=fen;
fen=max-english;
max-english=p-english;
p-english=fen;
fen=max-math;
max-math=p-math;
p-math=fen;
/*交换前后结点中的数学成绩 , 使之与姓名相匹配*/
}
}
p=head;
max=head;
}
print(head);
break;
case 3 :for(i=1;in;i++)
{for(j=i+1;j=n;j++)
{max=p;
p=p-next;
if(max-computerp-computer)
{
fen=max-computer;
max-computer=p-computer;
p-computer=fen;
k=max-number;
max-number=p-number;
p-number=k;
strcpy(t,max-name);
strcpy(max-name,p-name);
strcpy(p-name,t);
fen=max-english;
max-english=p-english;
p-english=fen;
fen=max-math;
max-math=p-math;
p-math=fen;
}
}
p=head;
max=head;
}
print(head);
break;
case 4 :for(i=1;in;i++)
{for(j=i+1;j=n;j++)
{max=p;
p=p-next;
if(max-englishp-english)
{
fen=max-english;
max-english=p-english;
p-english=fen;
k=max-number;
max-number=p-number;
p-number=k;
strcpy(t,max-name);
strcpy(max-name,p-name);
strcpy(p-name,t);
fen=max-computer;
max-computer=p-computer;
p-computer=fen;
fen=max-math;
max-math=p-math;
p-math=fen;
}
}
p=head;
max=head;
}
print(head);
break;
case 5 : for(i=1;in;i++)
{for(j=i+1;j=n;j++)
{max=p;
p=p-next;
if(max-mathp-math)
{
fen=max-math;
max-math=p-math;
p-math=fen;
k=max-number;
max-number=p-number;
p-number=k;
strcpy(t,max-name);
strcpy(max-name,p-name);
strcpy(p-name,t);
fen=max-computer;
max-computer=p-computer;
p-computer=fen;
fen=max-english;
max-english=p-english;
p-english=fen;
}
}
p=head;
max=head;
}
print(head);
break;
default :printf("输入错误,请重试! \n");
}
return (0);}
/*==============================================================================================*/
int menu(k)/*函数menu,功能:菜单选择界面*/
{
int i;
printf("\t\t\t\t学生信息管理系统\n");
for(i=0;i80;i++)
printf("*");
printf(" \t\t\t1添加学生记录\t\t\t\n");
printf(" \t\t\t2.显示学生记录\t\t\t\n");
printf(" \t\t\t3.删除学生记录\t\t\t\n");
printf(" \t\t\t4.查询学生记录\t\t\t\n");

推荐阅读