首页 > 试题广场 >

给定一个矩阵intmaxtrixA[m][n],每行和每列都

[问答题]
给定一个矩阵int maxtrixA[m][n],每行和每列都是增序的,实现一个算法去找矩阵中的某个元素element。
这题考的应该是折半查找吧,楼上那个代码不要误人子弟哦。
发表于 2015-07-20 16:05:54 回复(1)
#include
using namespace std;

const int M = 4;
const int N = 4;
int main
{
    int matrix[M][N] = {};
    double element;

    int flag = 1;
    for (int j = 0; j {
    if (matrix[i][j] == element)
            cout << "位置" < while ( flag --flag;
            while ( flagelement )
                ++flag;
            }
}
发表于 2014-10-25 00:26:14 回复(1)