1130 -- 矩阵找值

来源:互联网 发布:查找重复删除知乎 编辑:程序博客网 时间:2024/06/08 01:12

矩阵找值

Time Limit:2000MS  Memory Limit:65536K
Total Submit:218 Accepted:109

Description

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

Input

输入为一个4*3的矩阵

Output

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

Sample Input

样例输入:0 0 00 1 20 1 30 1 4

Sample Output

样例输出:4  3  2

Source

    using System;    using System.Collections.Generic;    using System.Linq;    using System.Text;    namespace AK1130 {        class Program {            static void Main(string[] args) {                string[] s;                int[,] a = new int[5, 5];                int max = -100000000, ii = 0, jj = 0;                for (int i = 0; i < 4; i++) {                    s = Console.ReadLine().Split();                    for (int j = 0; j < 3; j++) {                        a[i, j] = int.Parse(s[j]);                        if (a[i, j] > max) {                            max = a[i, j];                            ii = i;                            jj = j;                        }                    }                }                Console.WriteLine("{0} {1} {2}", max, ii, jj);                //Console.ReadLine();            }        }    }


0 0
原创粉丝点击