一个3行4列的二维数组,求出该二维数组每行的平均值,并依次放入一个
答案:1 悬赏:0
解决时间 2021-02-16 06:25
- 提问者网友:孤凫
- 2021-02-15 18:11
一个3行4列的二维数组,求出该二维数组每行的平均值,并依次放入一个
最佳答案
- 二级知识专家网友:动情书生
- 2021-02-15 18:42
#include
#include "stdlib.h"
#include "time.h"
int main(int argc,char *argv[]){
int a[3][4],i,j;
double b[3];
srand((unsigned)time(NULL));
for(i=0;i<3;i++){
for(b[i]=j=0;j<4;j++){
printf("%3d",a[i][j]=rand()%100);
b[i]+=a[i][j];
}
b[i]/=4;
printf("
");
}
printf("
Line1: %g
",b[0]);
printf("Line2: %g
",b[1]);
printf("Line3: %g
",b[2]);
return 0;
}
#include "stdlib.h"
#include "time.h"
int main(int argc,char *argv[]){
int a[3][4],i,j;
double b[3];
srand((unsigned)time(NULL));
for(i=0;i<3;i++){
for(b[i]=j=0;j<4;j++){
printf("%3d",a[i][j]=rand()%100);
b[i]+=a[i][j];
}
b[i]/=4;
printf("
");
}
printf("
Line1: %g
",b[0]);
printf("Line2: %g
",b[1]);
printf("Line3: %g
",b[2]);
return 0;
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯