Find in a two-dimensional array, the young matrix in a two-dimensional array, each row is ordered in ascending order from left to right. Each column is sorted in ascending order from top to bottom. Complete a function, enter an array and a number to determine if the array contains this number # include <stdio.h> #define COL 4#define rol 4int yang (int (*p) [col], int num) { int i = 0;int j = col-1;while (j+1) {int *q = & (P[i][j]), if (*q = num) return 1;else if (*q < num) {p++;} else if (*q > num) {--q;--j;}} return-1;} int main () {int Arr[rol][col] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, ten, one, and};p rintf ("%d\n", ya Ng (arr, 6));p rintf ("%d\n", Yang (arr.));p rintf ("%d\n", Yang (arr.));p rintf ("%d\n", Yang (arr, 1));p rintf ("%d\n", Yang (arr, +)); return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Find in "C" two-dimensional array, Young's matrix in a two-dimensional array, each row is sorted in ascending order from left to right, enter an array and a number to determine if the array contains this number