Advertisement
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 Filter_base
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, int> age = new Dictionary<string, int>();
- Dictionary<string, double> salary = new Dictionary<string, double>();
- Dictionary<string, string> position = new Dictionary<string, string>();
- string input = Console.ReadLine();
- while (input != "filter base")
- {
- string[] arr = input.Split(' ').ToArray();
- string name = arr[0];
- string info = arr[2];
- int valueInt;
- double valueDouble;
- if (int.TryParse(info, out valueInt))
- {
- age[name] = int.Parse(info);
- }
- else if (double.TryParse(info, out valueDouble))
- {
- salary[name] = double.Parse(info);
- }
- else
- {
- position[name] = info;
- }
- input = Console.ReadLine();
- }
- string sort = Console.ReadLine();
- switch (sort)
- {
- case "Age":
- foreach (KeyValuePair<string, int> person in age)
- {
- Console.WriteLine($"Name: {person.Key}");
- Console.WriteLine($"Age: {person.Value}");
- Console.WriteLine("{0}", new string('=', 20));
- }
- break;
- case "Salary":
- foreach (KeyValuePair<string, double> person in salary)
- {
- Console.WriteLine($"Name: {person.Key}");
- Console.WriteLine("Salary: {0:f2}", person.Value);
- Console.WriteLine("{0}", new string('=', 20));
- }
- break;
- case "Position":
- foreach (KeyValuePair<string, string> person in position)
- {
- Console.WriteLine($"Name: {person.Key}");
- Console.WriteLine($"Position: {person.Value}");
- Console.WriteLine("{0}", new string('=', 20));
- }
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement