From 782186bafa80a96bdc98e87074bf6252764485f9 Mon Sep 17 00:00:00 2001 From: anas12 Date: Thu, 19 Nov 2026 08:23:54 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20lab=2019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab 19 | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 lab 19 diff --git a/lab 19 b/lab 19 new file mode 100644 index 0000000..0e67247 --- /dev/null +++ b/lab 19 @@ -0,0 +1,90 @@ +fun main() { + val pokename = "Pikachu" + var pokelevel = 5 + var pokehp = 100 + val poketype = "Electric" + + println("Имя:$pokename, Нр:$pokehp, Уровень:$pokelevel, Тип:$poketype") + + pokelevel += 3 + pokehp -= 25 + + println("Имя:$pokename, Нр:$pokehp, Уровень:$pokelevel, Тип:$poketype") +} + +fun main() { + val hp = 35 + val level = 12 + + if (hp <= 0) { + println("Покемон повержен") + } else if (hp < 50) { + println("Покемон ранен, нужно лечение") + } else { + println("Покемон в порядке") + } +} + +fun main() { + val level = 42 + + val rank = if (level < 10) { + println("Новичок") + } else if (level < 30) { + println("Боец") + } else { + println("Чемпион") + } +} + +fun main() { + val type = "water" + + when (type) { + "fire" -> println("уязвим к воде") + "water" -> println("уязвим к траве") + "grass" -> println("уязвим к огню") + "electric" -> println("уязвим к земле") + else -> println("неизвестный тип") + } +} + +fun main() { + val type = 42 + + when (type) { + in 1..9 -> println("малыш") + in 10..29 -> println("подросток") + in 30..49 -> println("взрослый") + in 50..100 -> println("легенда") + else -> println("некорректный уровень") + } + + for (i in 1..10 ) print(i) + for (i in 10 downTo 1) print(i) + val team = listOf("Pickachu", "Charmander", "Squitle", "Bulbasaur") + for ((index, name) in team.withIndex())) { + println("$index . $name") + } + + +fun main() { +val myPokemons = mutableListOf("Eevee", "Snorlax", "Mew") +myPokemons.add("Pikachu") + +println(myPokemons.size) +println(myPokemons.last()) +myPokemons.contains("Mew") +var count = 0 +for (i in myPockemons) { +if (i/length > 4) +count++ +} +println(count) + + + +fun main() { +val wildPokemons = listOf("Rattata", "Pidgey", "Zubat") +wildPokemons.add("Pikachu") +