Advertisement
BloodMoonYTC

legnagyobbelem

Oct 24th, 2021
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System;
  2.  
  3. namespace legnagyobbelem
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             while (true)
  10.             {
  11.                 Console.Write("Sorok szama: ");
  12.                 int m = int.Parse(Console.ReadLine());
  13.                 Console.Write("Oszlopok szama: ");
  14.                 int n = int.Parse(Console.ReadLine());
  15.                 if (m == 0 || n == 0) break;
  16.                 int[,] mat = new int[m, n];
  17.                 Console.WriteLine("Matrix beolvasasa ");
  18.                 for (int i = 0; i < m; i++)
  19.                 {
  20.                     for (int j = 0; j < n; j++)
  21.                     {
  22.                         mat[i, j] = int.Parse(Console.ReadLine());
  23.                     }
  24.                 }
  25.                 int mi = 0, mj = 0;
  26.  
  27.                 for (int i = 0; i < m; i++)
  28.                 {
  29.                     for (int j = 0; j < n; j++)
  30.                     {
  31.                         if (mat[i,j] > mat[mi,mj])
  32.                         {
  33.                             mi = i;
  34.                             mj = j;
  35.                         }
  36.                     }
  37.                 }
  38.                 Console.WriteLine("Matrix legnagyobb eleme [{0},{1}] = {2}", mi, mj, mat[mi, mj]);
  39.              
  40.                 Console.ReadLine();
  41.             }
  42.         }
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement