输出在行、列中最大的数

Input

The first line has a number k(0<k<20), where k means there are k groups of test data. In the following lines, input the test data that are separated by one blank line. In each group, the test data is organized as follows:
1. The first line includes two positive integers: m(1<m<30) and n(1<n<30), representing the 2-dimensional array has m rows and n columns.
2. The following m lines include the element values of the 2-dimensional array. Each line has n values separated by one blank space.

Output

There are k results for all test data. One result per line. If there are several peak points, each two are separated by blank space. If there is no peak point, please display NO.

Sample Input

2
3 3
1 2 3
4 5 6
7 8 9

2 2
9 8
4 10

Sample Output

9
9 10
 
#include <stdio.h>
int main()
{
    int k,i,j,a[30][30],m,n,b,c,t,max,f;
	scanf("%d",&k);
	for(c=0;c<k;c++)
	{scanf("%d%d",&m,&n);
	for(i=0;i<m;i++)
	for(j=0;j<n;j++)
		scanf("%d",&a[i][j]);
	for(i=0;i<m;i++)
	{max=a[i][0];
	b=0;
	for(j=1;j<n;j++)
		if(a[i][j]>max)
		{max=a[i][j];
		b=j;}
		f=1;
		for(t=0;t<m;t++)
			if(max<a[t][b])
			{f=0;
			break;}
			if(f==1)
				printf("%d\n",max);}
	if(f==0)
				printf("no\n");
	
	}
	return 1;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值