Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace usersLogs
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split().ToArray();
- string ip = input[0];
- if (ip == "end")
- {
- return;
- }
- string user = input[2];
- List<string> allIp = new List<string>();
- List<string> allUsers = new List<string>();
- // username, IP's, countIP;
- var serverLogs = new Dictionary<string, Dictionary<string, int>>();
- while (true)
- {
- allIp.Add(ip.Substring(3));
- allUsers.Add(user.Substring(5));
- input = Console.ReadLine().Split().ToArray();
- ip = input[0];
- if (ip == "end")
- {
- break;
- }
- user = input[2];
- }
- var ipResult = new Dictionary<string, int>();
- int countSameIp = 1;
- for (int i = 0; i < allIp.Count; i++)
- {
- for (int j = i + 1; j < allIp.Count; j++)
- {
- if (allIp[i] == allIp[j])
- {
- countSameIp++;
- }
- }
- if (!ipResult.ContainsKey(allIp[i]))
- {
- ipResult[allIp[i]] = countSameIp;
- }
- if (!serverLogs.ContainsKey(allUsers[i]))
- {
- serverLogs[allUsers[i]] = ipResult;
- }
- countSameIp = 1;
- }
- foreach (var userLog in serverLogs)
- {
- Console.Write($"{userLog.Key}:");
- Console.WriteLine();
- for (int i = 0; i < userLog.Value.Keys.Count; i++)
- {
- Console.WriteLine($"{string.Join(" ", userLog.Value.Keys)} => {string.Join(" ", userLog.Value.Values)}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement