Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication5
- {
- class Program
- {
- static Boolean flag = false;
- static int max1 = 0;
- static void Main(string[] args)
- {
- int max2 = 0;
- Console.WriteLine("Podaj wiersze");
- int i = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Podaj kolumny");
- int j = Convert.ToInt32(Console.ReadLine());
- double[,] tab = new double[i, j];
- load(ref tab);
- show(tab);
- max1 = Max(tab);
- max2 = Max(tab);
- Console.WriteLine("Max1 : " + max1 + " Max2 : " + max2);
- Console.ReadKey();
- }
- static void load(ref double[,] tab)
- {
- Random xxx = new Random();
- for (int i = 0; i < tab.GetLength(0); i++)
- {
- for (int j = 0; j < tab.GetLength(1); j++)
- tab[i, j] = xxx.Next(0, 6);
- }
- }
- static void show(double[,] tab)
- {
- for (int i = 0; i < tab.GetLength(0); i++)
- {
- for (int j = 0; j < tab.GetLength(1); j++)
- Console.Write("{0} ", tab[i, j]);
- Console.WriteLine();
- }
- }
- static int Max(int[,] tab)
- {
- int max = 0;
- for (int i = 0; i < tab.GetLength(0); i++)
- for (int j = 0; j < tab.GetLength(1); j++)
- {
- if (!flag)
- {
- if (tab[i, j] > max) max = tab[i, j];
- }
- else
- {
- if (tab[i, j] > max && tab[i, j] != max1) max = tab[i, j];
- }
- }
- if (!flag) flag = true;
- return max;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement