#define _crt_secure_no_warnings 1 #include<stdio.h> #include<stdlib.h> int search_target(int arr[], int target, int row, int column) { int row = 0; int column = column - 1; if (arr != null && row > 0 && column > 0) { while (row < row && column >= 0) { if (arr[row * column + column] == target) { return 1; } else if (arr[row * column + column] < target) { ++row; } else if (arr[row * column + column] > target) { --column; } } return 0; } return 0; } int main() { int arr[][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int ret = search_target(arr, 7, 3, 3); if (ret == 1) { printf("existn"); } else { printf("not existn"); } system("pause"); return 0; }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/606752.html