我研究了好久,就想问几个问题,那些for语句的那个是怎么回事,还有?那个if的调换数据我看不懂啊,下面的是函数
void SortNumber()
{
//j,k用于实现冒泡排序,n用于判断是否排序完成
int j,k;
//用于两个结构体交换值,过渡变量
Student data;
//控制排序次数
for(j=0;j<i;j++)
{
//控制排序个数
for(k=0;k<i-1-j;k++)
{
//如果满足,调换数据
if(strcmp(students[k].number,students[k+1].number)>0)
{
data = students[k];
students[k] = students[k+1];
students[k+1] = data;
}
}
}
printf("正在根据学号排序,请稍等。。。。。。\n\n");
//输出排序结果
printf("--------------------------------------------------------------------------------- \n");
printf("%-15s%-15s%-15s%-10s%-10s%-10s%-10s\n","学号","姓名","班级","计算机","数学","英语","总成绩");
printf("--------------------------------------------------------------------------------- \n");
for(j=0;j<i;j++)
{
printf("%-15s%-15s%-15s%-10.1f%-10.1f%-10.1f%-10.1f\n",students[j].number, students[j].name, students[j].Class, students[j].computer, students[j].math, students[j].English, students[j].sum);
printf("--------------------------------------------------------------------------------- \n");
}
printf("\n\n排序完成!\n\n");
//退出函数