如何通过C语言建立一个求二维数组的某一行的最小值以及该最小值对应的列并返回列的函数
有一个二维数组a[5][5]={{0,50,21,29,13},{13,0,33,33,5.6},{19,12,0,24,12},{6.9,12,23,0,20},{28...
有一个二维数组a[5][5]={{0,50,21,29,13},{13,0,33,33,5.6},{19,12,0,24,12},{6.9,12,23,0, 20},{28,21,11,24,0}};请求帮忙用C语言建立一个
(1)求出每行每列的最小值、倒数第二小值并找到对应的列
(2)返回列 展开
(1)求出每行每列的最小值、倒数第二小值并找到对应的列
(2)返回列 展开
1个回答
展开全部
编写一个程序, 对于二维数组 b[2][3]={{1,2,3},{4,5,6}}, 验证*(*(b+i)+j)、 *(b[i]+j)、
(*(b+i))[j]与 b[i][j]是相同的。
*/
#include <iostream>
using namespace std;
void main()
{
int b[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
cout << "经检验:";
//if ((*(*(b + i) + j)) == (*(b[i] + j)) == ((*(b + i))[j]) == (b[i][j]))
{
//cout << "*(*(b+" << i << ")+" << j << ")==*(b[" << i << "] + " << j << ") == (*(b + " << i << "))[" << j << "] == b[" << i << "]["<< j << "]" << endl;
//cout << " b[" << i << "][" << j << "]" << "不成立!" << endl;
if (*(*(b + i) + j) == *(b[i] + j))
{
cout << "*(*(b+" << i << ")+" << j << ")==*(b[" << i << "] + " << j << ")";
}
if (*(b[i] + j) == (*(b + i))[j])
{
cout << "*(b[" << i << "] + " << j << ") == (*(b + " << i << "))[" << j << "]";
}
if ((*(b + i))[j] == b[i][j])
{
cout << " (*(b + " << i << "))[" << j << "] == b[" << i << "][" << j << "]" << endl;
}
}
}
}
system("pause");
}
(*(b+i))[j]与 b[i][j]是相同的。
*/
#include <iostream>
using namespace std;
void main()
{
int b[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
cout << "经检验:";
//if ((*(*(b + i) + j)) == (*(b[i] + j)) == ((*(b + i))[j]) == (b[i][j]))
{
//cout << "*(*(b+" << i << ")+" << j << ")==*(b[" << i << "] + " << j << ") == (*(b + " << i << "))[" << j << "] == b[" << i << "]["<< j << "]" << endl;
//cout << " b[" << i << "][" << j << "]" << "不成立!" << endl;
if (*(*(b + i) + j) == *(b[i] + j))
{
cout << "*(*(b+" << i << ")+" << j << ")==*(b[" << i << "] + " << j << ")";
}
if (*(b[i] + j) == (*(b + i))[j])
{
cout << "*(b[" << i << "] + " << j << ") == (*(b + " << i << "))[" << j << "]";
}
if ((*(b + i))[j] == b[i][j])
{
cout << " (*(b + " << i << "))[" << j << "] == b[" << i << "][" << j << "]" << endl;
}
}
}
}
system("pause");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询