Advertisement
Guest User

LOVEDANKA

a guest
Dec 15th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 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 dankalove
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var sladukshava = new SortedDictionary<string, string>();
  14.             string input = Console.ReadLine();
  15.  
  16.             while (input != "Lumpawaroo")
  17.             {
  18.                 if (input.Contains("|")) //0 - side , 1 - user
  19.                 {
  20.                     string[] spoko = input.Split(new[] { '|', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  21.                     if (!(sladukshava.ContainsKey(spoko[1])))
  22.                     {
  23.                         sladukshava.Add(spoko[1], spoko[0]);
  24.                     }
  25.                 }
  26.                 if (input.Contains("->")) // 0 - user, 1 - side
  27.                 {
  28.                     string[] spoko = input.Split(new[] { '-', '>', ' ' } , StringSplitOptions.RemoveEmptyEntries).ToArray();
  29.                     if (!(sladukshava.ContainsKey(spoko[0])))
  30.                     {
  31.                         sladukshava.Add(spoko[0], spoko[1]);
  32.                     }
  33.                     else
  34.                     {
  35.                         sladukshava[spoko[0]] = spoko[1];
  36.                         Console.WriteLine($"{spoko[0]} joins the {spoko[1]} side!");
  37.                     }
  38.                 }
  39.                 input = Console.ReadLine();
  40.             }
  41.             var leko = new SortedDictionary<string, int>();
  42.  
  43.             for (int i = 0; i < sladukshava.Count; i++)
  44.             {
  45.                 if (leko.ContainsKey(sladukshava.ElementAt(i).Value))
  46.                 {
  47.                     leko[sladukshava.ElementAt(i).Value]++;
  48.                 }
  49.                 else
  50.                 {
  51.                     leko.Add(sladukshava.ElementAt(i).Value, 1);
  52.                 }
  53.             }
  54.             for (int i = 0; i < leko.Count; i++)
  55.             {
  56.                 Console.WriteLine("Side: " + leko.ElementAt(i).Key + ", Members: " + leko.ElementAt(i).Value);
  57.                 string[] manqches = sladukshava.Where(pair => pair.Value == leko.ElementAt(i).Key).Select(pair => pair.Key).ToArray();
  58.                 for (int j = 0; j < manqches.Length; j++)
  59.                 {
  60.                     Console.WriteLine("! " + manqches[i]);
  61.                 }
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement