From 3cce26e72dad8159f7ebc9e5cc33051f7345069c Mon Sep 17 00:00:00 2001 From: studiosi Date: Wed, 12 Aug 2026 09:09:41 +0300 Subject: [PATCH] Solved: 06 - Conditionals --- modules/02_control_flow/src/conditionals.cpp | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/modules/02_control_flow/src/conditionals.cpp b/modules/02_control_flow/src/conditionals.cpp index b8931ae..5760f8c 100644 --- a/modules/02_control_flow/src/conditionals.cpp +++ b/modules/02_control_flow/src/conditionals.cpp @@ -2,21 +2,26 @@ namespace control_flow { -auto classify_score(int score) -> Grade { - // TODO: A>=90, B>=80, C>=70, D>=60, else F - (void)score; +auto classify_score(const int score) -> Grade { + if (score >= 90) return Grade::A; + if (score >= 80) return Grade::B; + if (score >= 70) return Grade::C; + if (score >= 60) return Grade::D; return Grade::F; } -auto max_of_three(int a, int b, int c) -> int { - (void)a; (void)b; (void)c; - return 0; +auto max_of_three(const int a, const int b, const int c) -> int { + if (a >= b) { + if (a >= c) return a; + if (c > a) return c; + } + if (b >= c) return b; + if (c > b) return c; + return -1; } -auto sign_of(int value) -> int { - // TODO: Return -1, 0, or 1 - (void)value; - return 0; +auto sign_of(const int value) -> int { + return value == 0 ? 0 : value > 0 ? 1 : -1; } } // namespace control_flow