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 ...
随机推荐
- jSP-13-其他
1. JAVAEE Ø Java平台版本 Java平台有3个版本: 适用于小型设备和智能卡的JavaME (Java Platform Micro Edition,Java 微型版) 适用于桌 ...
- 在linux中安装adb和fastboot工具
我用的是archlinux,在官方的软件仓库里就可以找到对应的包,包的名字叫:android-tools 据说debian系列的软件包是两个,分别是:android-tools-adb, androi ...
- Tomcat JSP提交参数中文乱码问题解决
参考: http://blog.csdn.net/error_case/article/details/8250209 中文乱码是个老生常谈的问题,一般情况下,只要保证页面,web服务器,数据库的编码 ...
- jquery file upload 文件上传插件
1. jquery file upload 下载 jquery file upload Demo 地址:https://blueimp.github.io/jQuery-File-Upload/ jq ...
- Xamarin
快速建立原生(Native)的行动装置应用程序: 程序代码共享: 与 Visual Studio 整合: 确保第一时间更新: 原生的应用程序效能:
- 关于easyUI 的tabs 在子页面增加显示tabs的一个问题
在父页面点个链接能动态看到子页面的情况太简单,请看easyUI官网:http://www.jeasyui.com/tutorial/layout/tabs2.php现在说的是在子页面点个按钮也能触发增 ...
- mysql重复索引、冗余索引、未使用索引的定义和查找
1.冗余和重复索引 mysql允许在相同列上创建多个索引,无论是有意还是无意,mysql需要单独维护重复的索引,并且优化器在优化查询的时候也需要逐个地进行考虑,这会影响性能.重复索引是指的在相同的列上 ...
- linux服务器默认连接数配置
vi /etc/security/limits.d/90-nproc.conf * - nofile 65536* - nproc 65536root soft nproc unlimited vi ...
- faster alter table add column
Create a new table (using the structure of the current table) with the new column(s) included. execu ...
- Java开发中经典的小实例-( 鸡蛋0.1元一个,鸭蛋3元一个,鹅蛋6元一个。求一百元买一百个蛋。)
public class Test24 { public static void main(String[] args) { // 鸡蛋0.1元一个,鸭蛋3元一个,鹅蛋6元一个.求 ...