From e2495c6bd4b9b26febe90f36ddef186af776307f Mon Sep 17 00:00:00 2001 From: Puzanova Date: Tue, 24 Nov 2026 10:30:48 +0300 Subject: [PATCH] new --- works/CSharp/task/task/Program.cs | 68 ++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/works/CSharp/task/task/Program.cs b/works/CSharp/task/task/Program.cs index 4a58d5f..b53d5f2 100644 --- a/works/CSharp/task/task/Program.cs +++ b/works/CSharp/task/task/Program.cs @@ -119,31 +119,51 @@ namespace task pokedex["Bulbasaur"] = 1; pokedex["Charmander"] = 2; pokedex["Zubat"] = 3; - -// // Проверка наличия -// if (pokedex.ContainsKey("Pikachu")) -// { -// Console.WriteLine(pokedex["Pikachu"]); // 25 -// } -// -// // Безопасное получение -// if (pokedex.TryGetValue("Missingno", out int num)) -// { -// Console.WriteLine(num); -// } -// else -// { -// Console.WriteLine("Нет в покедексе"); -// } -// -// // Перебор -// foreach (var pair in pokedex) -// { -// Console.WriteLine($"{pair.Key} -> {pair.Value}"); -// } -// -// +// Безопасное получение + if (pokedex.TryGetValue("Pikachu", out int num)) + { + Console.WriteLine(num); + } + else + { + Console.WriteLine("Нет в покедексе"); + } + +// Перебор + foreach (var pair in pokedex) + { + Console.WriteLine($"{pair.Key} -> {pair.Value}"); + } + + Console.WriteLine("задача 7"); + + var attack1 = new Dictionary(); + attack1["tackle"] = 20; + attack1["thunder"] = 40; + attack1["quick"] = 10; + int enemyHp = 75; + int turn = 0; + while (enemyHp > 0) + { + turn++; + switch (turn % 3) + { + case 0: + Console.WriteLine("tackle"); + break; + case 1: + Console.WriteLine("thunder"); + break; + default: + Console.WriteLine("quick"); + break; + } + + } + + + }