SHARE
TWEET

Untitled

a guest Nov 19th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     public class Program
  6.     {
  7.         public static void Main()
  8.         {
  9.             int minNumber, maxNumber;
  10.             int[,] matrix = new int[5, 5] { { 1, 2, 8, 9, 5 }, { 4, 6, 7, 3, 5 }, { 1, 8, 9, 7, 5 }, { 6, 3, 2, 8, 1 }, { 4, 7, 9, 3, 2 } };
  11.             minNumber = matrix[0, 0];
  12.             maxNumber = matrix[0, 0];
  13.  
  14.             for (int i = 0; i <= matrix.GetLength(0) - 1; i++)
  15.             {
  16.                 for (int j = 0; j <= matrix.GetLength(1) - 1 - 1; j++)
  17.                 {
  18.                     if (matrix[i, j] < minNumber)
  19.                     {
  20.                         minNumber = matrix[i, j];
  21.                     }
  22.  
  23.                     if (matrix[i, j] > maxNumber)
  24.                     {
  25.                         maxNumber = matrix[i, j];
  26.                     }
  27.                 }
  28.             }
  29.  
  30.             Console.WriteLine(minNumber + " " + maxNumber);
  31.         }
  32.     }
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top