matlab查找矩阵元素_C ++程序查找矩阵的最高和最低元素

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查找矩阵元素

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值