怎样用C语言编程计算二维数组每一行和每一列数的和? 麻烦测试好了发我哈!感激不尽!
答案:2 悬赏:30 手机版
解决时间 2021-01-10 05:43
- 提问者网友:动次大次蹦擦擦
- 2021-01-09 12:38
怎样用C语言编程计算二维数组每一行和每一列数的和? 麻烦测试好了发我哈!感激不尽!
最佳答案
- 五星知识达人网友:从此江山别
- 2021-01-09 13:52
#include
float score[5][6] = { 91, 79, 83, 92, 85, 80,
95, 72, 81, 90, 86, 82,
96, 80, 90, 92, 84, 88,
88, 80, 78, 86, 84, 80,
77, 76, 86, 88, 80, 85 };
void main(void){
float sum1[5] = {0,0,0,0,0};//行的和
float sum2[6] = { 0, 0, 0, 0, 0 ,0};//列的和
for (int i = 0; i < 5; i++){
for (int j = 0; j < 6; j++){
sum1[i]+= score[i][j];
}
printf_s("%f\n",sum1[i]);
}
printf_s("\n");
for (int i = 0; i < 6; i++){
for (int j = 0; j < 5; j++){
sum2[i] += score[j][i];
}
printf_s("%f\n", sum2[i]);
}
getchar();
}
float score[5][6] = { 91, 79, 83, 92, 85, 80,
95, 72, 81, 90, 86, 82,
96, 80, 90, 92, 84, 88,
88, 80, 78, 86, 84, 80,
77, 76, 86, 88, 80, 85 };
void main(void){
float sum1[5] = {0,0,0,0,0};//行的和
float sum2[6] = { 0, 0, 0, 0, 0 ,0};//列的和
for (int i = 0; i < 5; i++){
for (int j = 0; j < 6; j++){
sum1[i]+= score[i][j];
}
printf_s("%f\n",sum1[i]);
}
printf_s("\n");
for (int i = 0; i < 6; i++){
for (int j = 0; j < 5; j++){
sum2[i] += score[j][i];
}
printf_s("%f\n", sum2[i]);
}
getchar();
}
全部回答
- 1楼网友:愁杀梦里人
- 2021-01-09 14:20
我觉得你回去睡觉比较现实.
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯