6.3w+
社区成员
#include <iostream>
#include <iostream>
using namespace std;//在vs2005中
int main()
{
const size_t x = 4, y = 5;
int array[x][y], min_x, max_y;
size_t min_i = 0, max_j = 0;
bool judge = true;
cout<< "输入一个二维数组(" << x << "行" << y << "列):" << endl;
for (size_t ci = 0; ci != x; ++ci)
{
cout << "输入第" << ci + 1 << "行("
<< y << "个整数):" << flush;
for (size_t cj = 0; cj != y; ++cj)
{
cin >> array[ci][cj];
}
}
int k=0;
size_t i = 0;//在此你的程序设计思路也好像有问题。你是对每一行进行遍历后在去考虑列。
//其实 应该把列和行同时考虑。
for (; i != x; ++i) //先考虑 每一列的最大值是在哪一行
{
size_t j = 0;
max_y = array[i][j];
for (/**/; j != y; ++j)
if (max_y < array[i][j]) //这里少一个括号{ }还有输出问题自己改改吧!
{
max_y = array[i][j];
max_j = j;
}//找该行max_j
size_t fi = 0;
min_x = array[fi][max_j];
for (/**/; fi != x; ++fi) //考虑每一列。
{
if (min_x > array[fi][max_j])
{
min_x = array[fi][max_j];
min_i = fi;
}
if (i == min_i)
{
cout << "第" << min_i + 1 << "行"
<< max_j + 1 << "列的整数:"
<< array[min_i][max_j]
<< "是该数组的一个鞍点。" << endl;
judge = false;
}
}
}
if (judge)
{
cout << "该数组没有鞍点。" << endl;
}
return 0;
}
#include "stdafx.h"
#include <iostream>
using namespace std;//在vs2005中
int main()
{
const size_t x = 4, y = 5;
int array[x][y], min_x, max_y;
size_t min_i = 0, max_j = 0;
bool judge = true;
cout<< "输入一个二维数组(" << x << "行" << y << "列):" << endl;
for (size_t ci = 0; ci != x; ++ci)
{
cout << "输入第" << ci + 1 << "行("
<< y << "个整数):" << flush;
for (size_t cj = 0; cj != y; ++cj)
{
cin >> array[ci][cj];
}
}
int k=0;
size_t i = 0;
for (; i != x; ++i)
{
size_t j = 0;
max_y = array[i][j];
for (/**/; j != y; ++j)
if (max_y < array[i][j]) //这里少一个括号{ }还有输出问题自己改改吧!
{
max_y = array[i][j];
max_j = j;
}
size_t fi = 0;
min_x = array[fi][max_j];
for (/**/; fi != x; ++fi)
{
if (min_x > array[fi][max_j])
{
min_x = array[fi][max_j];
min_i = fi;
}
if (i == min_i)
{
cout << "第" << min_i + 1 << "行"
<< max_j + 1 << "列的整数:"
<< array[min_i][max_j]
<< "是该数组的一个鞍点。" << endl;
judge = false;
}
}
}
if (judge)
{
cout << "该数组没有鞍点。" << endl;
}
return 0;
}