zadacha5.cs 902 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace SedovaCheskinaProject
  7. {
  8. internal class zadacha5
  9. {
  10. public void mas()
  11. {
  12. Random r = new Random();
  13. int[,] array = new int[5, 5];
  14. Console.WriteLine("Данный массив: ");
  15. for (int i = 0; i < 5; i++)
  16. {
  17. for (int j = 0; j < 5; j++)
  18. {
  19. array[i, j] = r.Next(0, 50);
  20. Console.Write(array[i, j] + " ");
  21. }
  22. Console.WriteLine();
  23. }
  24. int sum = 0;
  25. int count = 0;
  26. foreach (int number in array)
  27. {
  28. sum += number;
  29. count++;
  30. }
  31. Console.WriteLine((double)sum / count);
  32. }
  33. }
  34. }