目前修改后的代码已经可以运行,你的具体需求没有写明,所以就只帮你修改了一些错误
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define N 10
extern int i, xuehao1;
struct fen
{
float gaoshu1;
float cyuyan1;
float tiyu1;
float yingyu1;
float zhongguogemingshi1;
};
struct student
{
char name[10];
int xuehao;
float gaoshu;
float cyuyan;
float tiyu;
float yingyu;
float zhongguogemingshi;
float average;
struct fen xuefen;
};
void found(struct student stu[N],int n);
float ave(struct student stu[N],int i);
int main()
{
struct student stu[N];
float zongxuefen[N];
float average[N];
int i;
int xuehao1;
int j, a = 0, b = 0, c = 0, d = 0;
float t;
char degree;
printf("请依次分别输入学生的姓名,高等数学,c语言程序设计,体育,英语,中国革命史成绩:\n");
for (i = 0; i < N; i++)
{
scanf("%c", &stu[i].name);
scanf("%f", &stu[i].gaoshu);
scanf("%f", &stu[i].cyuyan);
scanf("%f", &stu[i].tiyu);
scanf("%f", &stu[i].yingyu);
scanf("%f", &stu[i].zhongguogemingshi);
}
for (i = 0; i < N; i++)
{
if (stu[i].gaoshu >= 60)
stu[i].xuefen.gaoshu1 = 5;
else
stu[i].xuefen.gaoshu1 = 0;
if (stu[i].cyuyan >= 60)
stu[i].xuefen.cyuyan1 = 3.5;
else
stu[i].xuefen.cyuyan1 = 0;
if (stu[i].tiyu >= 60)
stu[i].xuefen.tiyu1 = 2;
else
stu[i].xuefen.tiyu1 = 0;
if (stu[i].yingyu >= 60)
stu[i].xuefen.yingyu1 = 3;
else
stu[i].xuefen.yingyu1 = 0;
if (stu[i].zhongguogemingshi >= 60)
stu[i].xuefen.zhongguogemingshi1 = 2;
else
stu[i].xuefen.zhongguogemingshi1 = 0;
average[i] = ave(stu,i);
zongxuefen[1] = stu[i].xuefen.gaoshu1 + stu[i].xuefen.cyuyan1 + stu[i].xuefen.tiyu1 + stu[i].xuefen.yingyu1 + stu[i].xuefen.zhongguogemingshi1;
}
for (i = 0; i < N; i++)
{
if (average[i] < 60)
degree = 'D';
if (60 <= average[i] && average[i] < 75)
degree = 'C';
if (75 <= average[i] && average[i] < 90)
degree = 'B';
if (90 <= average[i] && average[i] <= 100)
degree = 'A';
switch (degree)
{
case 'A':a++;
case 'B':b++;
case 'C':c++;
case 'D':d++;
}
}
printf("在分数段0~60的人有%d个\n", d);
printf("在分数段60~75的人有%d个\n", c);
printf("在分数段75~90的人有%d个\n", b);
printf("在分数段90~100的人有%d个\n", a);
printf("--------------------------------------------------\n");
printf("请输入要查找的学生的学号:\n");
scanf("%d", &xuehao1);
found(stu,xuehao1);
for (i = 0; i < 9; ++i)
{
for (j = 0; j < 9 - i; ++j)
{
if (zongxuefen[j] > zongxuefen[j + 1])
{
t = zongxuefen[j];
zongxuefen[j] = zongxuefen[j + 1];
zongxuefen[j + 1] = t;
}
}
}
for (j = 0; j < 10; ++j)
{
printf("%-5lf\n ", zongxuefen[j]);
}
return 0;
}
float ave(struct student stu[N],int i)
{
float sum;
sum = (stu[i].gaoshu + stu[i].cyuyan + stu[i].tiyu + stu[i].yingyu + stu[i].zhongguogemingshi);
return sum / 5;
}
void found(struct student stu[N],int xuehao1)
{
int i;
for (i = 0; i < N; i++)
{
if ((xuehao1 - stu[i].xuehao) == 0)
printf("名字:%s\n 高数成绩:%f\n c语言成绩:%f\n 体育成绩:%f\n 英语成绩:%f\n 中国革命史:%f\n", stu[i].name, stu[i].gaoshu, stu[i].cyuyan, stu[i].tiyu, stu[i].yingyu, stu[i].zhongguogemingshi);
}
}
|