标签:style blog color os io strong for div 问题
代码实现:
1 // 35.cc 2 #include <iostream> 3 #include <climits> 4 using namespace std; 5 6 int find_max(int (*a)[5], int m, int n) { 7 int max_sum = INT_MIN; 8 int sum; 9 10 for (int i = 0; i < m - 1; i++) { 11 for (int j = 0; j < n - 1; j++) { 12 sum = a[i][j] + a[i+1][j] + a[i][j+1] + a[i+1][j+1]; 13 max_sum = max(max_sum, sum); 14 } 15 } 16 return max_sum; 17 } 18 19 int main() { 20 int a[3][5] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {1, 2, 3, 4, 5}}; 21 cout << find_max(a, 3, 5) << endl; 22 return 0; 23 }
IT公司100题-35- 求一个矩阵中最大的二维矩阵(元素和最大)
标签:style blog color os io strong for div 问题
原文地址:http://www.cnblogs.com/dracohan/p/3962865.html