📄 stuins.c
字号:
/*以下为录入排序文件xs_ins.c的函数*/
/*以下为录入、排序文件头部分*/
#include "stuhead.h"
/*以下定义录入记录函数*/
void s_insert(struct xscj stud[])
{extern xhexist();
while(1)
{printf("学号:");
scanf("%s",stud[recno].xh);
if(xhexist(stud,stud[recno].xh,recno)==1)printf("该学号已经存在!\n");
else break;
}
printf("姓名:");
scanf("%s",stud[recno].xm);
printf("数学:");
scanf("%d",&stud[recno].match);
printf("计算机:");
scanf("%d",&stud[recno].computer);
printf("英语:");
scanf("%d",&stud[recno].english);
stud[recno].zf=stud[recno].match+stud[recno].computer+stud[recno].english;
recno++;
recount++;
printf("当前记录号=%d,总记录数=%d\n",recno,recount);
}
/*以下定义按总分排序记录函数*/
void s_sort(struct xscj stud[])
{int i,j,p;
extern s_disp();
struct xscj stu[30],chang;
for(i=0;i<recount;i++)
stu[i]=stud[i];
for(i=0;i<recount;i++)
{p=i;
for(j=i+1;j<recount;j++)
if(stu[j].zf>stu[p].zf) p=j;
if(p!=i)
{chang=stu[i];
stu[i]=stu[p];
stu[p]=chang;
}
}
getch();
s_disp(stu);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -