Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [StartCode]
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- /*
- * Создать программу, которая принимает от пользователя слово и выводит его значение. Если такого слова нет, то следует вывести соответствующее сообщение.
- */
- namespace ConsoleApp4
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Dictionary<int, string> shelf = new Dictionary<int, string>();
- shelf.Add(1, "Пушкин");
- shelf.Add(2, "Толстой");
- shelf.Add(3, "Лермонтов");
- shelf.Add(4, "Гоголь");
- shelf.Add(5, "Донцова");
- Console.Write("Укажите цифру :");
- int userInput = int.Parse(Console.ReadLine());
- DisplayAuthor(shelf, userInput);
- }
- static void DisplayAuthor(Dictionary<int, string> shelf, int userInput)
- {
- if (shelf.ContainsKey(userInput))
- {
- Console.WriteLine(shelf[userInput]);
- }
- else
- {
- Console.WriteLine("Таких писателей нету.");
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment