程序代码:
struct STUDENT
{
char number[20];
char name[20];
int c;
int yingyu;
int gaoshu;
};
void control();
void output(struct STUDENT s[],int n);
void max(struct STUDENT s[],int n);
void cyuyan_jigelv(struct STUDENT s[],int n);
void sangebujige(struct STUDENT s[],int n);
main()
{
control();
}
void control()
{
struct STUDENT s[10];
int i;
for(i=0;i<10;i++){
printf("请输入学号\n");
scanf("%s",s[i].number);
printf("请输入姓名\n");
scanf("%s",s[i].name);
printf("请输入c语言成绩\n");
scanf("%d",&s[i].c);
printf("请输入高数成绩\n");
scanf("%d",&s[i].gaoshu);
printf("请输入英语成绩\n");
scanf("%d",&s[i].yingyu);
}
output(s,10);
max(s,10);
cyuyan_jigelv(s,10);
sangebujige(s,10);
}
void output(struct STUDENT s[],int n){
int i;
for(i=0;i<n;i++){
printf("学号:%s\n",s[i].number);
printf("姓名:%s\n",s[i].name);
printf("c语言成绩:%d\n",s[i].c);
printf("英语成绩:%d\n",s[i].yingyu);
printf("高数成绩:%d\n",s[i].gaoshu);
}
}
void max(struct STUDENT s[],int n){
int m[10];
int i;
int da;
int ren;
for(i=0;i<n;i++)
{
m[i]=s[i].c+s[i].gaoshu+s[i].yingyu;
}
da=m[0];
for(i=0;i<n;i++){
if(m[i]>da)
da=m[i];
ren=i;
}
printf("靠最高分的学号为%s\n",s[ren].number);
printf("考最高分的为%s\n",s[ren].name);
printf("最高分为%d\n",da);
}
void cyuyan_jigelv(struct STUDENT s[],int n){
int i;
int jige=0;
float jigelv;
for(i=0;i<n;i++){
if(s[i].c>=60)
jige++;
}
jigelv=((float)jige/(float)n);
printf("c语言的及格率为%f",jigelv);
}
void sangebujige(struct STUDENT s[],int n){
int i;
int san_bujige=0;
for(i=0;i<n;i++){
if(s[i].c<60)
if(s[i].gaoshu<60)
if(s[i].yingyu<60)
san_bujige++;
}
printf("三门都不及格的人数为%d\n",san_bujige);
}