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;
- using System.Threading.Tasks;
- namespace ConsoleApplication23
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("TABLICA 1-WYMIAROWA");
- int[] tab = new int[10];
- Random r = new Random();
- for (int i = 0; i < tab.Length; i++)
- {
- tab[i] = r.Next(21);
- }
- WypiszTab(tab, "Elementy tablicy:");
- Console.WriteLine("\r\nElement najwiekszy = " + ElMax(tab));
- Console.WriteLine("\r\nElement najmniejszy = " + ElMin(tab));
- Console.ReadKey();
- }
- static void WypiszTab(int[] tab , string opis)
- {
- Console.WriteLine();
- Console.WriteLine(opis);
- foreach(int elem in tab)
- {
- Console.Write(elem + "\t");
- }
- }
- static int ElMax(int[] tab)
- {
- int max = tab[0];
- for (int i = 0; i < tab.Length; i++)
- {
- if(tab[i]>max)
- max = tab[i];
- }
- return max;
- }
- static int ElMin(int[] tab)
- {
- int min = tab[0];
- for (int i = 0; i < tab.Length; i++)
- {
- if(tab[i]<min)
- min = tab[i];
- }
- return min;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement