lovelyvook

Unit_32

Jul 3rd, 2024
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Ijunior
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Dictionary<string, string> countriesCapitals = new Dictionary<string, string>();
  11.  
  12.             countriesCapitals.Add("Нидерланды", "Амстердам");
  13.             countriesCapitals.Add("Сербия", "Белград");
  14.             countriesCapitals.Add("Венгрия", "Будапешт");
  15.             countriesCapitals.Add("Великобритания", "Лондон");
  16.             countriesCapitals.Add("Польша", "Варшава");
  17.             countriesCapitals.Add("Испания", "Мадрид");
  18.  
  19.             Console.Write("Введите страну Европы: ");
  20.             string userInput = Console.ReadLine();
  21.  
  22.             if (countriesCapitals.ContainsKey(userInput))
  23.             {
  24.                 Console.WriteLine($"Страна - {userInput}, Столица -  {countriesCapitals[userInput]}");
  25.             }
  26.             else
  27.             {
  28.                 Console.WriteLine("Такой страны в списке нет");
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment