georgimanov

13 AvrLoadTime

Apr 13th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 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<string> matrix = new List<string>();
  10.  
  11.         string line = " ";
  12.         string skipLine = " ";
  13.         while (line != string.Empty)
  14.         {
  15.             line = Console.ReadLine();
  16.             if(line != "")
  17.             matrix.Add(line);
  18.         }
  19.  
  20.         List<string> webSites = new List<string>();
  21.  
  22.         for (int i = 0; i < matrix.Count; i++)
  23.         {
  24.             String[] values = matrix[i].Split(' ');
  25.             webSites.Add(values[2]);
  26.         }
  27.  
  28.         List<string> printWebSite = new List<string>();
  29.  
  30.         for (int i = 0; i < webSites.Count; i++)
  31.         {
  32.             if (!printWebSite.Contains(webSites[i]))
  33.             {
  34.                 printWebSite.Add(webSites[i]);
  35.             }
  36.         }
  37.  
  38.         double counter = 0;
  39.         double time = 0;
  40.  
  41.         for (int i = 0; i < printWebSite.Count; i++)
  42.         {
  43.             for (int j = 0; j < webSites.Count; j++)
  44.             {
  45.                 if (webSites[i] == webSites[j])
  46.                 {
  47.                     String[] values = matrix[j].Split(new Char[] { ' ' });
  48.                     time += double.Parse(values[3]);
  49.                     counter++;
  50.                 }
  51.             }
  52.             Console.WriteLine("{0} -> {1}", printWebSite[i], time / counter);
  53.             counter = 0;
  54.             time = 0;
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment