From 25ae267ef2af0f31469c3ef39b7e8332dccc2013 Mon Sep 17 00:00:00 2001 From: fdai7754 Date: Sun, 4 Feb 2024 18:54:52 +0100 Subject: [PATCH] refactoring: optimierung der tierfakten funktion durch else if --- src/ageinseconds.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ageinseconds.c b/src/ageinseconds.c index 6d00ff7..4bc3512 100644 --- a/src/ageinseconds.c +++ b/src/ageinseconds.c @@ -35,31 +35,31 @@ int tierfakten(int age) { printf("%s", fakt[0]); } - if (age <= 6 && age > 4) { + else if (age <= 6 && age > 4) { printf("%s", fakt[1]); } - if (age <= 14 && age > 6) { + else if (age <= 14 && age > 6) { printf("%s", fakt[2]); } - if (age <= 20 && age > 14) { + else if (age <= 20 && age > 14) { printf("%s", fakt[3]); } - if (age <= 29 && age > 20) { + else if (age <= 29 && age > 20) { printf("%s", fakt[4]); } - if (age <= 47 && age > 29) { + else if (age <= 47 && age > 29) { printf("%s", fakt[5]); } - if (age <= 95 && age > 47) { + else if (age <= 95 && age > 47) { printf("%s", fakt[6]); } - if (age > 95) { + else { printf("%s", fakt[7]); }