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;
- using System.Text.RegularExpressions;
- class UserLogs
- {
- static void Main()
- {
- string input = Console.ReadLine();
- string pattern = @"\s+";
- string[] substrings = Regex.Split(input, pattern);
- Dictionary<string, int> combinations = new Dictionary<string, int>();
- for (int i = 0; i < substrings.Length - 1; i++)
- {
- if (combinations.ContainsKey(substrings[i] + " " + substrings[i + 1]))
- {
- int currentValue = combinations[substrings[i] + " " + substrings[i + 1]];
- combinations[substrings[i] + " " + substrings[i + 1]] = currentValue + 1;
- }
- else
- {
- combinations.Add(substrings[i] + " " + substrings[i + 1], 1);
- }
- }
- int total = 0;
- foreach (var item in combinations)
- {
- total += item.Value;
- }
- foreach (var item in combinations)
- {
- Console.WriteLine("{0} -> {1:F2}%", item.Key, ((double)item.Value / (double)total) * 100);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement