# 6-2 pointer and the sum fraction of each column of array matrix 10 this problem requires the implementation of a function to find the sum of each column of a two-dimensional array with n (less than 10) rows and 7 columns. The columns and are stored in a o

2022-04-29 14:29:59

This question requests to realize a function , Ask for one n ( Less than 10) That's ok 7 A two-dimensional array of columns . Store the columns and in at least 7 In a one-dimensional array of cells .

### Function interface definition ：

``````void fun ( int  data[][7],  int  result[ ],  int n)
``````

The first parameter data Is a two-dimensional array , The second parameter result It's a one-dimensional array , The third parameter n Is the number of rows of a two-dimensional array , Is also the size of a one-dimensional array .

### Sample referee test procedure ：

`````` Here is an example of a function being called for testing . for example ：
#include <stdio.h>
void fun( int  data[][7],  int result[ ],  int n);
int main()
{ int  i, k,n,a[10][7],b[7];
scanf("%d",&n);
for(i=0;i<n;i++)
for(k=0;k<7;k++)
scanf("%d",&a[i][k]);
fun(a,b,n);
for(i=0;i<7;i++) printf("%d ",b[i]);
return 0;
}

### sample input ：

The first line input is the number of rows of the two-dimensional array n, Here's the array n Row data , Each row 7 A unit .

``````5
1 0 0 0 0 0 1
1 0 0 1 0 0 0
0 0 0 1 0 0 1
0 0 1 0 1 0 0
1 0 0 0 0 1 0
``````

### sample output ：

``````3 0 1 2 1 1 2
``````
``````void fun ( int  data[][7],  int  result[ ],  int n)
{
int i,j,sum,k;
for(j=0;j<7;j++)
{
sum=0;
for(i=0;i<n;i++)
{
sum=sum+data[i][j];
}
result[k]=sum;
k++;
}

}
``````