desislava_topuzakova

Demo: Средно аритметично

Mar 20th, 2022
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _1._MatrixInputOutput
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int rows = int.Parse(Console.ReadLine());
  10.             int cols = int.Parse(Console.ReadLine());
  11.  
  12.             int[,] numbers = new int[rows, cols];
  13.             double sum = 0; //сума на елементите
  14.             int count = rows * cols; //брой на елементите
  15.  
  16.             //input matrix
  17.             for (int row = 0; row <= rows - 1; row++)
  18.             {
  19.                 for (int col = 0; col <= cols - 1; col++)
  20.                 {
  21.                     numbers[row, col] = int.Parse(Console.ReadLine());
  22.                     sum += numbers[row, col];
  23.                 }
  24.             }
  25.  
  26.             //средно аритметично
  27.             double average = sum / count;
  28.             Console.WriteLine(average);
  29.         }
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment