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 _1
- {
- class Program
- {
- static int[] PodawanieLiczb()
- {
- int ilość;
- Console.WriteLine("Ile liczb chcesz podać? ");
- ilość = Convert.ToInt32(Console.ReadLine());
- if (ilość == 0)
- {
- Environment.Exit(0);
- }
- int liczba;
- int[] tablica = new int[ilość];
- for (int i = 0; i < ilość; i++)
- {
- Console.Write("Podaj liczbę: ");
- liczba = Convert.ToInt32(Console.ReadLine());
- tablica[i] = liczba;
- }
- return tablica;
- }
- static int ZwróćMaksimum(int [] tab)
- {
- int maksimum;
- maksimum = tab[0];
- for (int i = 0; i < tab.Length; i++)
- {
- if (maksimum < tab[i])
- {
- maksimum = tab[i];
- }
- }
- return maksimum;
- }
- static void Main(string[] args)
- {
- int[] tablica = PodawanieLiczb();
- int max = ZwróćMaksimum(tablica);
- Console.WriteLine(max);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement