C语言编程用二维数组定义5个学生4门成绩,有独立的输入输出函数,求每

C语言编程用二维数组定义5个学生4门成绩,有独立的输入输出函数,求每个学生的平均分放在最右列,每科成绩的平均分放在最下行... C语言编程用二维数组定义5个学生4门成绩,有独立的输入输出函数,求每个学生的平均分放在最右列,每科成绩的平均分放在最下行 展开
 我来答
匿名用户
2016-11-18
展开全部
#include <stdio.h>
#include <stdlib.h>
void getscore(float s[6][5])
{
 int i,j;
 float t;
 for(i=0;i<5;i++)
  for(j=0;j<4;j++)
   { scanf("%f",&t); s[i][j]=t;}
}
void printscore(float s[6][5])
{
 int i,j;
 for(i=0;i<6;i++){
  for(j=0;j<5;j++)
   printf("%5.2g",s[i][j]);
  printf("\n");
 }
}
void aver(float a[6][5])
{
 int i,j;
 float s,cs[4];
 for(j=0;j<4;j++) cs[j]=0;
 for(i=0;i<5;i++){
  s=0;
  for(j=0;j<4;j++){
   s += a[i][j];
   cs[j] += a[i][j]/5;
  }
  a[i][4]=s/4;
 }
 s=0;
 for(j=0;j<4;j++){ a[5][j]=cs[j]; s+=cs[j]; }
 a[5][4] = s/4;
}
int main()
{
 float score[6][5];
 getscore(score);
 aver(score);
 printscore(score);
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式