</pre><pre name="code" class="html">#include <iostream> #include <cstdio> using namespace std; bool findnum(int *numbers,int cols,int rows,int number); int main() { int n=5; int a[5][5]; for(int i=0;i<n;i++) for(int j=0;j<n;j++) a[i][j]=i*n+j; if(findnum(&a[0][0],5,5,30)) printf("YES "); else printf("NO "); return 0; } bool findnum(int *numbers,int cols,int rows,int number) { if(numbers==NULL) return false; int col=cols-1; int row=0; while(col>=0&&row<rows) { if(number<numbers[cols*row+col]) col--; if(number>numbers[row*cols+col]) row++; if(number==numbers[row*cols+col]) return true; } return false; }