fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. int lowerBound = -10;
  10. int upperBound = 10;
  11. Random rnd = new Random();
  12. int[] tablica;
  13. tablica = new int[10];
  14. int max = lowerBound;
  15. int min = upperBound;
  16. double suma = 0;
  17.  
  18. int lowerCount = 0;
  19. int higherCount = 0;
  20. double avg = suma / 10;
  21.  
  22. for (int i = 0; i < tablica.Length; i++)
  23. {
  24. tablica[i] = rnd.Next(lowerBound, upperBound + 1);
  25. Console.WriteLine(tablica[i]);
  26.  
  27. if (tablica[i] > max)
  28. {
  29. max = tablica[i];
  30. }
  31. else if (tablica[i] < min)
  32. {
  33. min = tablica[i];
  34. }
  35.  
  36. else if (tablica[i] > avg)
  37. {
  38. higherCount++;
  39. }
  40. else if (tablica[i] < avg)
  41. {
  42. lowerCount++;
  43. }
  44.  
  45. suma = suma + tablica[i];
  46.  
  47. }
  48.  
  49. Console.WriteLine("Nawiększy element: " + max + " i " + "Najmniejszy element: " + min);
  50.  
  51. Console.WriteLine("Średnia arytmetyczna to: " + suma / 10);
  52. //Console.WriteLine("ilość liczb większych od średniej: " + higherCount + " i " + "ilość liczb mniejszej od średniej: " + lowerCount);
  53. Console.ReadKey();
  54. }
  55. }
Success #stdin #stdout 0s 29664KB
stdin
Standard input is empty
stdout
-4
-1
-9
-1
5
-4
7
-8
3
-6
Nawiększy element: 7 i Najmniejszy element: -9
Średnia arytmetyczna to: -1.8