#includeusing namespace std; bool find(int arr[4][4],int cl,int ro,int nu){ bool found=false; int cloum=cl-1; int rows=0; if(arr!=NULL&&cl>0&&ro>0){ while(rows=0){ if(arr[rows][cloum]==nu){ found=true; cout<<arr[rows][cloum]<<" rows:"<<rows+1<<" cloum: "<<cloum+1<nu){ cloum--; }else{ rows++; } } } } return found; } int main(){ int a[4][4]={ {1,2,8,9}, {2,4,9,12}, {4,7,10,13}, {6,8,11,15} }; for(int i=0;i<4;i++){ for(int j=0;j<4;j++){ cout<<a[i][j]<<" "; } cout<>f){ cout<<find(a,4,4,f)<<endl; } return 0; }
作者心情:昨夜西风凋碧树,独上高楼,望尽天涯路。
如无特殊说明,文章均为本站原创,转载请注明出处
- 转载请注明来源:二维数组中的查找
- 本文永久链接地址:http://icehill.cn/post/single/info/66.html