Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Rextester
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- //Your code goes here
- double[,] tablica = {
- {1 ,2 ,3},
- {4 ,5 ,6},
- {7, 8, 1}
- };
- Console.WriteLine("Najnizsza srednia: {0}", Average(tablica));
- }
- public static double Average(double[,] tablica)
- {
- int liczbaWierszy = tablica.GetLength(0);
- int liczbaKolumn = tablica.GetLength(1);
- double[] sumaKolumn = new double[liczbaKolumn];
- for (int w = 0; w < liczbaWierszy; w++)
- {
- for (int k = 0; k < liczbaKolumn; k++)
- {
- sumaKolumn[k] += tablica[w, k];
- }
- }
- for (int i = 0; i < liczbaKolumn; i++)
- {
- sumaKolumn[i] = sumaKolumn[i] / liczbaWierszy;
- }
- return sumaKolumn.Min();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement