用函数来算平均分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分享举报

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值