C语言C语言的问题 储存五名学生的信息 姓名学号总成绩 输出最高分最低分的

C语言的问题 储存五名学生的信息 姓名学号总成绩 输出最高分最低分的

我只是将你的searchMaxScore函数修改了一下成为查找最低分,你试一下对不对

void searchMinScore(struct student stu[])
{
int i,index=0;//index用来存储最高分的学生的索引值

float min = stu[0].computerScore;
for(i=1;i i<=N;i++)
if(stu[i].computerScore<max)
{
min=stu[i].computerScore;
index=i;
}
}

#include
#define N 3
struct student
{
char num[6];
char name[20];
float computerScore;
}
stu[N];

void input(struct student stu[])
{
int i;
printf("please enter the information of student:\n");
for(i=0;i<N;i++)
{
printf("请你输入%d(学号换行姓名换行成绩)然后输入下个人的......:",i+1);
scanf("%s %s %f",&stu[i].num,&stu[i].name,&stu[i].computerScore);//学号姓名成绩 num name score
}
}

void searchMaxScore(struct student stu[])
{
int i,index=0;//index用来存储最高分的学生的索引值
float max = stu[0].computerScore;
for(i=1;i {
if(stu[i].computerScore>max)
{
max=stu[i].computerScore;
index=i;
}
}
printf("The highest 成绩是 %2f,姓名是 %s and 学号 is %s\n",max,stu[index].name,stu[index].num);
}

void main()
{
input(stu);
searchMaxScore(stu);
}

不好意思,上面那个发错了,用这个

void searchMinScore(struct student stu[])
{
int i,index=0; //index用来存储最低分的学生的索引值

float min = stu[0].computerScore;
for(i=1; i<=N; i++)
if(stu[i].computerScore<min)
{
min=stu[i].computerScore;
index=i;
}
}

怎么在里面加一个输出最低分!