Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApp1
  7. {
  8.  
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Podaj rozmiar: ");
  14. string liczba = Console.ReadLine();
  15.  
  16. int size = int.Parse(liczba);
  17.  
  18. int[] tab = new int[10];
  19. for(int i=0;i<size;i++)
  20. {
  21. Console.WriteLine("Podaj liczbe: ");
  22. string numer = Console.ReadLine();
  23. int parsednumer = int.Parse(numer);
  24. tab[i] = parsednumer;
  25. }
  26.  
  27.  
  28.  
  29. wlasciwosci(tab);
  30. void wlasciwosci(int[] tab)
  31. {
  32. Console.WriteLine("Suma: ");
  33. Console.WriteLine(sumaElementow(tab));
  34. int x = sumaElementow(tab);
  35. Console.WriteLine("Srednia: ");
  36. Console.WriteLine(srednia(size,x));
  37. Console.WriteLine("Minimum ");
  38.  
  39.  
  40. }
  41.  
  42. int sumaElementow(int[] tab)
  43. {
  44. int sum = 0;
  45. for (int i = 0; i < size; i++)
  46. {
  47. sum += tab[i];
  48. }
  49. return sum;
  50. }
  51. float srednia(float size, float sum)
  52. {
  53. float avg = sum / size;
  54. return avg;
  55. }
  56.  
  57.  
  58.  
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement