[Arrays]D. Liang 6.17 Summing the all the numbers in a matrix

Description

Write a function that sums all the integers in a matrix of integers.

The matrix is 4 * 4. Using the flowing function header:

int sumMatrix(int matrix[4][4])

Hint

You should submit the implementation of the function but do not submit the main() function.

Problem Source: 程序设计I Chapter6 Arrays

Source.h

int sumMatrix(int matrix[4][4]);
//   Date:2020/4/24
//   Author:xiezhg5
int sumMatrix(int matrix[4][4])
{
    int i,j,sum=0;
    for(i=0;i<4;i++)
    for(j=0;j<4;j++)
    sum=sum+matrix[i][j];  //计算矩阵所有元素之和 
    return sum;
}
原创文章 268 获赞 307 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_45645641/article/details/105742435