#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <stdlib.h> #include <math.h> #include<windows.h> int find(int arr[], int rows, int columns, int num) { int find = 0; if (arr != NULL && rows > 0 && columns > 0) { int row = 0; int column = columns - 1; while (row < rows && column >= 0) { if (arr[row*columns + column] == num) { find = 1; break; } else if (arr[row*columns + column] > num) { column--; } else { row++; } } } return find; } int main() { int arr[3][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int ret=find(arr, 3, 3, 7); if (ret == 1) { printf("EXIST!!!!\n"); } else { printf("NOT EXIST!!!\n"); } system("pause"); return 0; }
【C语言】【面试题】【笔试题】二维数组中的查找,杨氏矩阵
原创
©著作权归作者所有:来自51CTO博客作者安下的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Java 中数组的使用(一维数组和二维数组)
本文详细的介绍了,在Java 中数组的使用,并对其内存存在形式进行了详细的分析。
数组 一维数组 二维数组 java基础 -
剑指offer | 面试题3:二维数组的查找
面试题3: 二维数组中的查找
二维数组 spring 时间复杂度