Files
2026-11-24 11:17:22 +00:00

139 lines
4.2 KiB
C#

// http://5.35.127.219:3001/admin/daily-24.11-228/src/branch/main/task.md
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Zadania_1();
Zadania_2();
Zadania_3();
Zadania_4();
Zadania_5();
}
static void Zadania_1()
{
Console.WriteLine("Задача 1. Переменные покемона");
string name = Console.ReadLine();
string type = Console.ReadLine();
int level = int.Parse(Console.ReadLine() ?? "");
int hp = int.Parse(Console.ReadLine());
double attack = double.Parse(Console.ReadLine());
bool isShiny = false;
Console.WriteLine($"{name},{type},LVL: {level},HP: {hp},Atk: {attack},shiny: {isShiny}");
level = level + 1;
hp = hp - 30;
Console.WriteLine("Изменение данных.");
Console.WriteLine($"{name},{type},LVL: {level},HP: {hp},Atk: {attack},shiny: {isShiny}");
}
static void Zadania_2()
{
string[] types = { "fire", "water", "electric", "dragon" };
foreach (string attackerType in types)
{
if (attackerType == "fire")
{
Console.WriteLine("Огонь силён против травы");
}
else if (attackerType == "water")
{
Console.WriteLine("Вода сильна против огня");
}
else if (attackerType == "grass")
{
Console.WriteLine("Трава сильна против воды");
}
else if (attackerType == "electric")
{
Console.WriteLine("Электричество сильно против воды");
}
else
{
Console.WriteLine("Тип не изучен");
}
}
}
static void Zadania_3()
{
string name = "water";
switch (name)
{
case "fire":
Console.WriteLine("Огонь");
break;
case "water":
Console.WriteLine("Вода");
break;
case "grass":
Console.WriteLine("Трава");
break;
default:
Console.WriteLine("Неизвестный тип");
break;
}
}
static void Zadania_4()
{
int hp = 100;
int round = 0;
while (hp > 0)
{
round++;
hp -= 17;
}
Console.WriteLine($"Покемон продержался {round} раундов, HP = {hp}");
for (int i = 0; i <= 10; i++)
{
if (i % 3 == 0) continue;
if (i == 7) break;
if (i % 2 != 0)
{
Console.Write($"{i}");
}
}
}
static void Zadania_5()
{
List<string> Pokemon = new List<string>() { "Pokemon 1", "Pokemon 2", "Charmander", "Pokemon 4" };
Console.WriteLine($"Количество покимонов: {Pokemon.Count}");
for (int i = 0; i < Pokemon.Count; i++)
{
Console.WriteLine($"{i}:{Pokemon[i]}");
}
Pokemon.Remove("Pokemon 2");
Pokemon.Add("Pokemon 5");
Console.WriteLine($"\n Новое количество: {Pokemon.Count}");
bool estCharmander = Pokemon.Contains("Charmander");
string otvet = estCharmander ? "Да, Charmander есть в команде" : "Нет, Charmander отсутствует";
Console.WriteLine(otvet);
}
static void Zadania_6()
{
}
}
}