用函数来算平均分c语言,3.输入5个学生3门课的成绩,分别用函数实现下列功能: A)计算每个学生的平均分 B)计算每门课的平均分 C)...

满意答案

00e27ab806e4881f8254fe7ae8741834.png

vxufh

2013.10.10

00e27ab806e4881f8254fe7ae8741834.png

采纳率:51%    等级:12

已帮助:10462人

你好!求二位数组的行列总和可以考虑用双重for循环语句来实现。

一下是学生成绩系统:

可以实现:(1) 求各门课的平均分;

(2) 找出有两门以上不及格的学生,并输出其学号和不及格课程的成绩;

(3) 找出三门课平均成绩在85-90分的学生,并输出其学号和姓名

#include

void main(void)

{

int i,j,elect,num,count,average_score;

struct student

{

int yuwen;

int yingyu;

int shuxue;

int count;

float average_score;

}stu[5]={{78,45,76,0,0},{65,78,90,0,0},{29,46,63,0,0},{34,98,59,0,0},{80,90,99,0,0}};

for(i=0;i<5;i++)

{

stu[i].count=stu[i].yuwen+stu[i].yingyu+stu[i].shuxue;

stu[i].average_score=stu[i].count/3.0;

}

printf("1.students' score demand\n2.look for disqualified student\n3.look for good student\n\nplease input your elect number:\n");

scanf("%d",&elect);

switch(elect)

{

case 1:printf("\nplease input the number fo student[1-5]\n");

scanf("%d",&num);

printf("yuwen=%d,yingyu=%d,shuxue=%d,count=%d,average=%f",stu[num-1].yuwen,

stu[num-1].yingyu,stu[num-1].shuxue,stu[num-1].count,stu[num-1].average_score);break;

case 2:for(i=0;i<5;i++)

{

if(stu[i].yuwen<60&&stu[i].yingyu<60&&stu[i].shuxue<60||stu[i].yuwen<60&&stu[i].yingyu<60||stu[i].yuwen<60&&stu[i].shuxue<60|| stu[i].yingyu<60&&stu[i].shuxue<60)

printf("student number is:%d,\nthe score is:%d,%d,%d\n\n",i,stu[i].yuwen,stu[i].yingyu,stu[i].shuxue);

}break;

case 3:for(i=0;i<5;i++)

{if(80<=stu[i].average_score&&stu[i].average_score<=100)printf("the student number is:%d\nscore:%f\n\n",i+1,stu[i+1].average_score);}break;

default:printf("you input error!!!");

}

getch();

}

03分享举报