Advertisement
paskal06

Untitled

Jul 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 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 LambadaExpressions
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var Elements = new Dictionary<string,string>();
  14.             var ElementsCount = new Dictionary<string, int>();
  15.             string input = Console.ReadLine();
  16.             while(input != "lambada")
  17.             {
  18.                 if (input=="dance")
  19.                 {
  20.                     //ElementsCount.Keys.ToList().ForEach(k => ElementsCount[k] = ElementsCount[k] + 1);
  21.                     ElementsCount = ElementsCount.ToDictionary(p => p.Key, p => p.Value+1);
  22.                     input = Console.ReadLine();
  23.                     continue;
  24.                 }
  25.  
  26.                 string[] inputTokens=input.Split(new string[] { " => " }, StringSplitOptions.None);
  27.                 string[] Data = inputTokens[1].Split('.');
  28.  
  29.                 string Selector = inputTokens[0];
  30.                 string SelectorObject = Data[0];
  31.                 string property = Data[1];
  32.  
  33.                 if (!Elements.ContainsKey(Selector))
  34.                 {
  35.                     Elements.Add(Selector, property);
  36.                     ElementsCount.Add(Selector, 1);
  37.                 }
  38.                 Elements[Selector] = property;
  39.                
  40.  
  41.                 input = Console.ReadLine();
  42.             }
  43.  
  44.             foreach(var group in Elements)
  45.             {
  46.                 Console.Write(group.Key + " => ");
  47.                 for (int i = 0; i < ElementsCount[group.Key]; i++)
  48.                 {
  49.                     Console.Write("{0}.",group.Key);
  50.                 }
  51.                 Console.WriteLine(group.Value);
  52.             }
  53.            
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement