Advertisement
dsavov_02

avg

Mar 23rd, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int rowsCount = int.Parse(Console.ReadLine());
  8.         int colsCount = int.Parse(Console.ReadLine());
  9.         int[,] matrix = new int[ rowsCount,colsCount];
  10.        
  11.         for ( int row=0 ;row < matrix.GetLength(0);row++)
  12.         {
  13.             for(int col=0;col<matrix.GetLength(1);col++)
  14.             {
  15.                 matrix[row, col] = int.Parse(Console.ReadLine());
  16.             }
  17.         }  
  18.         for ( int row=0 ;row < matrix.GetLength(0); row++)
  19.             {
  20.                 double avg = 0;
  21.             for(int col=0;col < matrix.GetLength(1); col++)
  22.             {
  23.                 Console.Write(matrix[row, col] + " " );
  24.                 avg +=matrix[row, col];
  25.             }
  26.             Console.WriteLine(avg/ matrix.GetLength(1));
  27.             }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement