首页 > 其他 > 详细

一些项目——鞍点计算

时间:2015-06-28 15:39:54      阅读:99      评论:0      收藏:0      [点我收藏+]

Description

找出具有m行n列二维数组Array的“鞍点”,即该位置上的元素在该行上最大,在该列上最小,其中1<=m,n<=10。

Input

输入数据有多行,第一行有两个数m和n,下面有m行,每行有n个数。

Output

按下列格式输出鞍点: Array[i][j]=x 其中x代表鞍点,i和j为鞍点所在的数组行和列下标,我们规定数组下标从0开始。 一个二维数组并不一定存在鞍点,此时请输出None。 我们保证不会出现两个鞍点的情况,比如:

3 3

1 2 3

1 2 3

3 6 8

Sample Input

3 3
1 2 3
4 5 6
7 8 9

Sample Output

Array[0][2]=3


代码

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    int x,y,i,j,m,p,x1,y1;
    bool g;
    cin>>x>>y;
    int a[x][y];
    for(i=0; i<x; ++i)
        for(j=0; j<y; ++j)
        {
            cin>>a[i][j];
        }
    for(i=0; i<x; i++)
    {
        m=0;
        for(j=0; j<y; ++j)
        {
            if(a[i][j]>m)
            {
                m=a[i][j];
                  x1=i;
                  y1=j;
            }
        }
        g=true;
        for(p=0;p<y;++p)
        {
            if(a[p][y1]<m)
                 g=false;
        }
        if(g)
            cout<<"Array["<<x1<<"]["<<y1<<"]="<<m;
    }
    return 0;
}



一些项目——鞍点计算

原文:http://blog.csdn.net/blue_skyrim/article/details/46670983

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!