Solved: 06 - Conditionals
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user