Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Random rand = new Random();
  14.  
  15.             const int N = 10;
  16.             int[,] array = new int[N, N];
  17.  
  18.  
  19.             int max = 0;
  20.             for (int i = 0; i < N; i++)
  21.             {
  22.                 for (int j = 0; j < N; j++)
  23.                 {
  24.                     array[i, j] = rand.Next(0, 100); //rand.Next(-100, 100);
  25.                     Console.Write(array[i, j] + " ");
  26.                     if (array[i, j] > max)
  27.                     {
  28.                         max = array[i, j];
  29.                     }
  30.                 }
  31.                
  32.                 Console.WriteLine();
  33.             }
  34.  
  35.             Console.WriteLine("Max Element: " + max);
  36.             Console.Write("Equals Max: ");
  37.             for (int i = 0; i < N; i++)
  38.             {
  39.                 for (int j = 0; j < N; j++)
  40.                 {
  41.                     if(array[i, j] == max)
  42.                     {
  43.                         Console.Write("[" + i + ", " + j + "]" + " ");
  44.                     }
  45.                 }
  46.             }
  47.             Console.WriteLine();
  48.  
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement