Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
157
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 ConsoleApplication23
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("TABLICA 1-WYMIAROWA");
  14. int[] tab = new int[10];
  15. Random r = new Random();
  16. for (int i = 0; i < tab.Length; i++)
  17. {
  18. tab[i] = r.Next(21);
  19.  
  20. }
  21. WypiszTab(tab, "Elementy tablicy:");
  22. Console.WriteLine("\r\nElement najwiekszy = " + ElMax(tab));
  23. Console.WriteLine("\r\nElement najmniejszy = " + ElMin(tab));
  24.  
  25.  
  26. Console.ReadKey();
  27. }
  28. static void WypiszTab(int[] tab , string opis)
  29. {
  30. Console.WriteLine();
  31. Console.WriteLine(opis);
  32. foreach(int elem in tab)
  33. {
  34. Console.Write(elem + "\t");
  35. }
  36.  
  37. }
  38. static int ElMax(int[] tab)
  39. {
  40. int max = tab[0];
  41. for (int i = 0; i < tab.Length; i++)
  42. {
  43. if(tab[i]>max)
  44. max = tab[i];
  45. }
  46. return max;
  47. }
  48. static int ElMin(int[] tab)
  49. {
  50. int min = tab[0];
  51. for (int i = 0; i < tab.Length; i++)
  52. {
  53. if(tab[i]<min)
  54. min = tab[i];
  55. }
  56. return min;
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement