From a2855a40aab162757036ca838eebef53ce428248 Mon Sep 17 00:00:00 2001 From: nillkiggers <6996@gmail.com> Date: Mon, 5 Oct 2026 08:18:55 +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=20works/algorhytm/kotlin-4-3.kt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- works/algorhytm/kotlin-4-3.kt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 works/algorhytm/kotlin-4-3.kt diff --git a/works/algorhytm/kotlin-4-3.kt b/works/algorhytm/kotlin-4-3.kt new file mode 100644 index 0000000..1aa5a89 --- /dev/null +++ b/works/algorhytm/kotlin-4-3.kt @@ -0,0 +1,22 @@ +fun main() { + println("=== ЗАДАНИЕ 3: АТАКА С МОНЕТКОЙ ===") + print("Введите лимит энергии: ") + var energyLimit = readln().toInt() + var rollCount = 0 + + if (energyLimit > 0) { + do { + rollCount++ + energyLimit-- + print("Бросок №\$rollCount (1-орел, 0-решка): ") + val coinResult = readln().toInt() + + if (coinResult == 1) { + println("Бросок №\$rollCount: Орёл! Урон нанесен. Осталось энергии: \$energyLimit") + } else { + println("Бросок №\$rollCount: Решка! Атака сорвалась.") + break + } + } while (energyLimit > 0) + } +}