怎样用C语言编程计算二维数组每一行和每一列数的和? 麻烦测试好了发我哈!感激不尽! 5
比如floatscore[5][6]={91,79,83,92,85,80,95,72,81,90,86,82,96,80,90,92,84,88,88,80,78,86...
比如
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}; 展开
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}; 展开
展开全部
#include<iostream>
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();
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-08-04
展开全部
我觉得你回去睡觉比较现实.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询