一些项目——鞍点计算
2015-06-28 13:34
225 查看
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; }
相关文章推荐
- JVM 类加载过程
- Linux输入子系统模型
- 始终感觉作者没有找准点子,留着以后打作者的脸
- spring结合时,web.xml的配置
- auto_ptr、shared_ptr、weak_ptr、scoped_ptr用法小结
- 害怕的东西真的遇到了
- 狄马:荒谬的苦难哲学
- 链表的各种递归非递归遍历
- Var Function(_JX_)
- 高考完第一天
- Material Design控件使用(二)
- 处处可导 但导函数不连续的例子
- 开源运动的破坏性效应
- Material Design控件使用(一)
- Java Web应用程序:Oozie及其使用方式
- VC++调用天气预报Web services方法
- MyEclipse各种好用的自定义配置(SVN, JDK, Maven, Tomcat, 自动补全, UTF-8, 字体等)
- CentOs Linux 常见命令
- M.Goffredo -Self-Calibrating View-Invariant Gait Biometrics读后记
- 设计模式之二十一:中介者模式(Mediator)