Problem 7-4 elements in the rows of the Matrix and (15 minutes)

This problem requires programming, seeking a given m × n-matrix and the elements of each row.

Input formats:

Input of the first line gives two positive integers m and n-( . 1). Subsequently m rows, each row gives the n integers therebetween

Separated by a space.

Output formats:

Each row corresponding to the output elements of the matrix and row.

Sample input:

3 2
6 3
1 -8
3 12
 

Sample output:

9
-7
15





#include<stdio.h>
int main(void)
{
    int m,n,i,j;
    int a[6][6];
    int b[6]={0};
    
    scanf("%d%d",&m,&n);
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            scanf("%d",&a[i][j]);
            b[i]=a[i][j]+b[i];
        }
    }
    for(i=0;i<m;i++)
        printf("%d\n",b[i]);
        
    return 0;    
}

 

Guess you like

Origin www.cnblogs.com/Kimsohyun/p/12608147.html