This function that I created needs to calculate the sum of each column of the array and store it in a vector position. However, it is not giving the desired result, I think it can be within the third% of%.
Can anyone help me with regard to saving the result of the sum of the array in the vector?
void soma(int mat[] [MAX], int n, int m, int v[])
{
int i,j,soma=0;
int res, x=0;
for (i = 0; i < n; i ++)
{
for ( j = 0; j < m ;j ++)
{
for(x=0; x < m; x++)
{
soma=soma+ mat[i][j];
res[v]=soma;
printf(" %d\n",res );
}
}
}
}