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.Threading.Tasks;
- namespace Dict_Ref
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, int> dictRef = new Dictionary<string, int>();
- string[] input = Console.ReadLine().Split(new char[] { ' ', '=' }, StringSplitOptions.RemoveEmptyEntries);
- while (input[0] != "end")
- {
- string keyInput = input[0];
- string valueInput = input[1];
- int numValue;
- if (int.TryParse(valueInput, out numValue))
- {
- dictRef[keyInput] = numValue;
- }
- else
- {
- if (dictRef.ContainsKey(valueInput))
- {
- dictRef[keyInput] = dictRef[valueInput];
- }
- }
- input = Console.ReadLine().Split(new char[] { ' ', '=' }, StringSplitOptions.RemoveEmptyEntries);
- }
- foreach (KeyValuePair<string,int> item in dictRef)
- {
- Console.WriteLine($"{item.Key} === {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment