又是这个问题
#include
#include
#define N 5
struct student
{
char name[10];
float score;
};
int main()
{
student stu[N];
float sum = 0.0;
float t_score[N];
int i;
int j;
float temp;
printf("输入学生名字 成绩,例如:小明 90\n");
for(i = 0; i < N; ++i)
{
scanf("%s", stu[i].name);
scanf("%f", &stu[i].score);
t_score[i] = stu[i].score;
sum += stu[i].score;
}
for(i = 0; i < N-1; ++i)
{
for(j = i+1; j < N; ++j)
{
if(t_score[i] > t_score[j])
{
temp = t_score[i];
t_score[i] = t_score[j];
t_score[j] = temp;
}
}
}
printf("按成绩从小到大排序:\n");
for(i = 0; i < N; ++i)
{
for(j = 0; j < N; ++j)
{
if(t_score[i] == stu[j].score)
{
printf("%s %0.2f\n", stu[j].name, stu[j].score);
}
}
}
printf("成绩总和:%0.2f\n", sum);
return 0;
}