1 /*************************************************************************
2 > File Name: 001.c
3 > Author: Juntaran
4 > Mail: JuntaranMail@gmail.com
5 > Created Time: 2016年08月24日 星期三 01时15分09秒
6 ************************************************************************/
7
8 #include <stdio.h>
9
10 #define ROW 4
11 #define COL 4
12
13 void Young(int array[][COL], int key)
14 {
15 int i = ROW - 1;
16 int j = 0;
17 int val;
18
19 while (i>=0 && j<COL)
20 {
21 val = array[i][j];
22 if (val == key)
23 {
24 printf("Find! [%d,%d]\n", i, j);
25 return;
26 }
27 if (val < key)
28 {
29 j ++;
30 }
31 if (val > key)
32 {
33 i --;
34 }
35 }
36 printf("Not Find!\n");
37 }
38
39 int main()
40 {
41 int array[ROW][COL] = {{1,2,8,9}, {2,4,9,12}, {4,7,10,13}, {6,8,11,15}};
42 int key = 10;
43 Young(array, key);
44 return 0;
45 }