1307:矩阵找值

来源:互联网 发布:禁止在淘宝网上发布 编辑:程序博客网 时间:2024/06/08 07:23

1307:矩阵找值


Descriptiion


现有一个4*3的矩阵,要求编写程序求出其中的最大的元素值,并输出其所在的行,列号。


Input


输入为一个4*3的矩阵。


OUtput

输出为矩阵中最大的数,并输出其在数组中的位置(行和列的位置从0开始)


Sample Input


0 0 0

0 1 2

0 1 3

0 1 4


Sa,plee Output


4  3  2


HINT


用一个空格隔开


Source


安科第一届新生ACM赛


#include<iostream>using namespace std;int main(){    int a[4][3]={0},i,j,bigest,x,y;    for(i=0;i<4;i++)    {        for(j=0;j<3;j++)        {            cin>>a[i][j];        }    }bigest=a[0][0];for(i=0;i<4;i++){    for(j=0;j<3;j++)    {       if(a[i][j]>bigest)        {            bigest=a[i][j];   x=i;   y=j;        }    }}cout<<bigest<<" "<<x<<" "<<y;return 0;}