Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class test
- {
- static void Main()
- {
- string[] line = Console.ReadLine().Split();
- var dict = new Dictionary<string, int>();
- while (line[0] != "end")
- {
- string firstName = line[0];
- string secondPart = line[2];
- bool isNumber = int.TryParse(secondPart, out int num);
- if (isNumber)
- {
- dict[firstName] = num;
- }
- else
- {
- if (dict.ContainsKey(secondPart))
- {
- dict[firstName] = dict[secondPart];
- }
- }
- line = Console.ReadLine().Split();
- }
- foreach (var item in dict)
- {
- Console.WriteLine($"{item.Key} === {item.Value}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment