package com.cxz.question3;
/*
* 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。
* 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
* */
public class Demo3 {

public static void main(String[] args) {
, , , }, {, , , }, {, , , }, {, , , }};
System.));
System.));
System.));
}

public static boolean find(int[][] matrix, int number) {
//输入判断条件
 || matrix[].length < ) {
return false;
}

int rows = matrix.length;
].length;

;
;

//判断查找的位置确保在数组内
 && row < rows && col >=  && col < cols) {
if (matrix[row][col] == number) {
return true;
} else if (matrix[row][col] > number) {
col--;
} else {
row++;
}
}

return false;
}

}

最新文章

  1. 【转】随机函数 rand() srand() 以及seed的原理
  2. Android -- TextView、button方法详解(2)
  3. MC3190终端配置冷启动自动恢复的方法
  4. 循序渐进Python3(二) -- 数据类型
  5. hihocode 1077 : RMQ问题再临-线段树
  6. css中元素居中总结
  7. :root
  8. Android之ExpandableListView的属性(Group不展开)
  9. 数据库索引的实现原理(笔记)详细http://www.linezing.com/blog/?p=798#nav-1
  10. 在Laravel中使用swoole来取代nginx作为http服务器
  11. Java中子类能继承父类的私有属性吗?
  12. linux Cacti监控服务器搭建
  13. json 格式化的时候,日期格式化
  14. [Swift]LeetCode470. 用 Rand7() 实现 Rand10() | Implement Rand10() Using Rand7()
  15. Confluence 6 的系统配置信息的示例
  16. Git 设置过滤忽略的文件或文件夹(ignore file)
  17. Centos 安装Percona Toolkit工具集
  18. 1.line (线)
  19. GlobalMemoryStatusEx获取内存
  20. AngularJS 的常用特性(二)

热门文章

  1. web前端基础知识-(七)Django进阶
  2. 移动端自适应:flexible.js可伸缩布局使用
  3. Fedora中显示windows下的文件
  4. 美团HD(3)-加载分类导航数据
  5. db2look导出ddl 详细用法(转)
  6. Velocity 局部定制模板
  7. sql表分区
  8. 玩QQ游戏,见到好几个图像是美女的QQ,就不始玩
  9. android:clipChildren属性的作用
  10. PYTHON map()函数详解