IT公司100题-35- 求一个矩阵中最大的二维矩阵(元素和最大)
代码实现:
// 35.cc
#include <iostream>
#include <climits>
using namespace std; int find_max(int (*a)[], int m, int n) {
int max_sum = INT_MIN;
int sum; for (int i = ; i < m - ; i++) {
for (int j = ; j < n - ; j++) {
sum = a[i][j] + a[i+][j] + a[i][j+] + a[i+][j+];
max_sum = max(max_sum, sum);
}
}
return max_sum;
} int main() {
int a[][] = {{, , , , }, {, , , , }, {, , , , }};
cout << find_max(a, , ) << endl;
return ;
}
IT公司100题-35- 求一个矩阵中最大的二维矩阵(元素和最大)的更多相关文章
- HDU 6336 (规律 + 二维矩阵的前缀和妙用)
题目 给出长度为n 的A矩阵 , 按 int cursor = 0; for (int i = 0; ; ++i) { for (int j = 0; j <= i; ++j) { M[j][i ...
- [LeetCode] Search a 2D Matrix II 搜索一个二维矩阵之二
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
- [CareerCup] 11.6 Search a 2D Matrix 搜索一个二维矩阵
11.6 Given an M x N matrix in which each row and each column is sorted in ascending order, write a m ...
- [LeetCode] 240. Search a 2D Matrix II 搜索一个二维矩阵 II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
- [LeetCode] Search a 2D Matrix 搜索一个二维矩阵
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
- 求一个Map中最大的value值,同时列出键,值
求一个Map中最大的value值,同时列出键,值 方法1. public static void main(String[] args){ Map map=new HashMap(); map.p ...
- [LeetCode] 74. Search a 2D Matrix 搜索一个二维矩阵
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
- 《剑指Offer》第1题(Java实现):在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
一.题目描述 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该 ...
- lintcode :搜索二维矩阵
题目: 搜索二维矩阵 写出一个高效的算法来搜索 m × n矩阵中的值. 这个矩阵具有以下特性: 每行中的整数从左到右是排序的. 每行的第一个数大于上一行的最后一个整数. 样例 考虑下列矩阵: [ [1 ...
随机推荐
- servletFileUpload
引用:http://bbs.csdn.net/topics/390290685?page=1 Java code? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...
- iOS开发Hessian
HessianKit使用参考资料比较少,通过摸索,把测试过程贴出来,代码很乱,未整理,先实现功能,再应用到项目中.供新手参考.如有问题,跟帖指正... HessianService与Java Serv ...
- windows进程详解
1:系统必要进程system process 进程文件: [system process] or [system process]进程名称: Windows内存处理系统进程描述: Windows ...
- Ubuntu16.04搭建LAMP架构服务器
安装Apache: weirubo@weirubo-VirtualBox:~$ sudo apt-get install apache2 查看Apache版本: weirubo@weirubo-Vi ...
- 2015弱校联盟(1) - C. Censor
C. Censor Time Limit: 2000ms Memory Limit: 65536KB frog is now a editor to censor so-called sensitiv ...
- TortoiseGit 连接每次都要输入用户名和密码
当你配置好git后,在C:\Documents and Settings\Administrator\ 或者 C:\Users\Administrator 目录下有一个 .gitconfig 的文件 ...
- Linux设置ssh无密码登陆
最近在折腾Hadoop,要用到主机间无密码登陆,设置的时候遇到了一些问题,这里记录一下. 假设A需要无密码登陆B. 那么首先需要在A上使用ssh-keygen生成id_rsa.pub的公钥,生成时,一 ...
- ns3 Tutorial 中的日志模块(翻译)
转载地址:http://blog.sina.com.cn/s/blog_8ecca79b0101d7fe.html 1 日志模块的使用 在运行 first.cc 脚本时,我们已经简单 ...
- JVM学习——编译OpenJDK
最近在学习<深入理解java虚拟机 第二版>这本书.书中第一部分建议大家自己编译OpenJDK.抱着学习态度也来编译个玩一玩.下面进入正题. 1.编译环境介绍 操作系统 CentOS Li ...
- ie兼容问题整理
1.连续发请求问题 * jquery(document).ready(function(){}) * 连续发请求ie8出问题,被拦截问题,url后边加时间戳 * 例 url : url+ ...