解题思路:先进行矩阵的行和列的确定,运用了一个while循环,先确定了n的值,然后在进行对每个坐标的赋值
,随便在其中找出最大值,并且确定行列坐标,
注意事项:这里运用了头文件climits,来赋值temp
参考代码:
#include<iostream>
#include<climits>
int main(int argc, char const *argv[])
{
using namespace std;
int arr[7][7];
int n;
int temp = INT_MIN;
int m;
int k;
while(cin >> n)
{
if(n > 6 || n < 1)
{
// cin.clear();
// cout << "Enter:";
continue;
}
else
break;
}
// cout << "Enter num:" << n << endl;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
cin >> arr[i][j];
if(arr[i][j] > temp)
{
temp = arr[i][j];
k = i;
m = j;
}
}
}
cout << temp << " " << k << " " << m << endl;
return 0;
}
0.0分
0 人评分
C二级辅导-分段函数 (C语言代码)浏览:567 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:439 |
买不到的数目 (C++代码)浏览:868 |
C语言训练-阶乘和数* (C语言代码)-------- 呆板写法浏览:1374 |
钟神赛车 (C语言代码)浏览:606 |
简单的a+b (C语言代码)浏览:418 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:1007 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:680 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:720 |
C二级辅导-统计字符 (C语言描述——用函数求解)浏览:1197 |