Advertisement
georgimanov

Problem 13. Average Load Time Calculator

Apr 13th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class AvrLoadTimeCalc
  6. {
  7.     static void Main(string[] args)
  8.     {
  9.         List<List<string>> matrix = new List<List<string>>();
  10.  
  11.         string line = " ";
  12.         while (line != string.Empty)
  13.         {
  14.             line = Console.ReadLine();
  15.             String[] values = line.Split(new Char[] { ' ' });
  16.             matrix.Add(new List<String>(values));
  17.         }
  18.  
  19.         List<string> webSites = new List<string>();
  20.  
  21.         for (int i = 0; i < matrix.Capacity - 1; i++)
  22.         {
  23.             webSites.Add(matrix[i][2]);
  24.         }
  25.  
  26.         Console.WriteLine(new string('-', 30));
  27.  
  28.         webSites.Sort();
  29.         List<string> printWebSite = new List<string>();
  30.  
  31.         double counter = 0;
  32.         double time = 0;
  33.  
  34.         for (int i = 0; i < webSites.Capacity - 1; i++)
  35.         {
  36.             for (int j = 0; j < webSites.Capacity - 1; j++)
  37.             {
  38.                 if (webSites[i] == webSites[j])
  39.                 {
  40.                     time += double.Parse(matrix[i][3]);
  41.                     counter++;
  42.                 }
  43.             }
  44.             if (!printWebSite.Contains(webSites[i]))
  45.             {
  46.                 Console.WriteLine("{0} -> {1}", webSites[i], time / counter);
  47.                 counter = 0;
  48.                 time = 0;
  49.                 printWebSite.Add(webSites[i]);
  50.             }
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement