3X3列表格式,
杨氏矩阵:
#include<stdio.h> void check(int arry[][3],int number) { int i = 0; int j = 0; while(i <= 2 && j <= 2) { if(arry[i][2]<number) { i++; if(arry[2][j] < number) { j++; } } else { for(;j < 3;j++) { if(number == arry[i][j]) { printf( "找到%d",number); return; } else if (j == 2) { i++; j = 0; } } } } printf( "找不到%d" ,number); } int main() { int arry[3][3] = {1,2,3,4,5,9,6,7,11}; int chNumber = 0; printf( "请输入一个数y" ); scanf( "%d",&chNumber); check(arry,chNumber); return 0; }
时间: 2024-10-03 22:48:54