Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 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 _1
  8. {
  9. class Program
  10. {
  11. static int PobierzLiczbe(string Nagłówek)
  12. {
  13. Console.Write(Nagłówek);
  14. int liczba = Convert.ToInt32(Console.ReadLine());
  15. return liczba;
  16. }
  17. static int[] tab = new int[PobierzLiczbe("Wprowadź ilość liczb,które chcesz wprowadzić ")];
  18. static int ZwróćMaksimum()
  19. {
  20. int maks = tab[0];
  21. for (int i = 0; i < tab.Length; i++) if (maks < tab[i]) maks = tab[i];
  22. return maks;
  23. }
  24. static int ZwróćMinimum()
  25. {
  26. int min = tab[0];
  27. for (int i = 0; i < tab.Length; i++) if (min > tab[i]) min = tab[i];
  28. return min;
  29. }
  30.  
  31. static void Main(string[] args)
  32. {
  33. while (true)
  34. {
  35.  
  36. int liczba = tab.Length;
  37. if (liczba == 0) break;
  38. for (int i = 0; i < tab.Length ; i++)
  39. {
  40. tab[i] = PobierzLiczbe("Wprowadź liczbę ");
  41. }
  42. Console.WriteLine("Maks = " + ZwróćMaksimum() + " min = " + ZwróćMinimum());
  43. Console.ReadKey();
  44. Console.Clear();
  45. tab = new int[PobierzLiczbe("Wprowadź ilość liczb,które chcesz wprowadzić ")];
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement