Advertisement
Guest User

Untitled

a guest
Apr 6th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace AverageLoadTimeCalculator
  8. {
  9.     class AverageLoadTimeCalculator
  10.     {
  11.         static void Main()
  12.         {
  13.  
  14.             Console.WriteLine("Write next report: ");
  15.             string line = Console.ReadLine();
  16.             Dictionary<string, double> sites = new Dictionary<string, double>();
  17.             Dictionary<string, int> counters = new Dictionary<string, int>();
  18.             int counter = 1;
  19.             while (line != string.Empty)
  20.             {
  21.                 string[] list = line.Split(' ');
  22.                 string link = list[2];
  23.                 double loadTime = double.Parse(list[3]);
  24.                
  25.                 if (!sites.Keys.Contains(link))
  26.                 {
  27.                     sites[link] = loadTime; counters.Add(link, 1);
  28.                 }
  29.                 else
  30.                 {
  31.                     counters[link] +=1;
  32.                     sites[link] = sites[link] + loadTime;
  33.                 }
  34.                 Console.WriteLine("Write line:");
  35.                 line = Console.ReadLine();
  36.             }
  37.             foreach (string link in sites.Keys)
  38.             {
  39.                 Console.WriteLine("{0} = {1:F7}",link,sites[link]/counters[link]);
  40.             }          
  41.  
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement