二维数组求每一行的和

 

输入一个4*3表,计算每一行的和。

Inut:
12个整数在4*3表中

输出:
4个整数,每一个在单行中

输入样例:

12 4 6

8 23 3

15 7 9

2 5 17

输出样例:

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
#include<stdio.h>

int main(){
	int res[4];
	int i,j;
	int count = 0;
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			int temp;
			scanf("%d",&temp);
			count += temp;
		}
		res[i]=count;
		count=0;
	} 
	for(i=0;i<4;i++){
		printf("%d\n",res[i]);
	}
	return 0;
}