matlab查找矩阵元素
Here you will get a C++ program to find highest or largest and lowest or smallest element of a matrix.
在这里,您将获得一个C ++程序来查找矩阵的最高或最高和最低或最小的元素。
#include<iostream>
using namespace std;
int main()
{
int m,n,a[10][10],i,j,high,low;
cout<<"Enter no. of rows and coloumns:";
cin>>m>>n;
cout<<"\nEnter matrix:\n";
for(i=0;i<m;++i)
{
for(j=0;j<n;++j)
cin>>a[i][j];
}
high=a[0][0];
low=a[0][0];
for(i=0;i<m;++i)
{
for(j=0;j<n;++j)
{
if(a[i][j]>high)
high=a[i][j];
else
if(a[i][j]<low)
low=a[i][j];
}
}
cout<<"\nHeighst Element:"<<high<<"\nLowest Element:"<<low<<"\n";
return 0;
}
Output
输出量
3
3
Enter matrix: 3 5 9 15 6 0 12 4 7
输入矩阵: 3 5 9 15 6 0 12 4 7
Highest Element:15 Lowest Element:0
最高元素:15 最低元素:0
翻译自: https://www.thecrazyprogrammer.com/2011/03/c-program-to-find-highest-and-lowest.html
matlab查找矩阵元素