From dedf9598af8953bb0012403019558af0e340b53e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corvin=20K=C3=B6hne?= Date: Tue, 9 May 2023 07:17:27 +0200 Subject: [PATCH] main: remove deep indentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Many levels of indentation are hard to read and confusing. So, you should try to avoid them. Signed-off-by: Corvin Köhne --- main.c | 70 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/main.c b/main.c index 3836cc2..2e40aa0 100644 --- a/main.c +++ b/main.c @@ -504,40 +504,42 @@ int colourValue(char colour[]) int checkResistorLogic(char input[], int count) { //test the first ring on logic - if(checkRing(count, 1, &input[0])) - { - //test the second ring on logic - if(checkRing(count, 2, &input[8])) - { - //test the third ring on logic - if(checkRing(count, 3, &input[16])) - { - //If more than three rings - if(count >3) - { - //check the fourth ring on logic - if(checkRing(count, 4, &input[24])) - { - //If more than four rings - if(count >4) - { - //check the fifth ring on logic - if(checkRing(count, 5, &input[32])) - { - //If more than five rings - if(count>5) - { - //check the sixth ring on logic - if(checkRing(count, 6, &input[40]))return true; - }else return true; - } - }else return true; - } - }else return true; - } - } - } - return false; + if(!checkRing(count, 1, &input[0])) + return false; + + //test the second ring on logic + if(!checkRing(count, 2, &input[8])) + return false; + + //test the third ring on logic + if(!checkRing(count, 3, &input[16])) + return false; + + //If more than three rings + if(count <= 3) + return true; + + //check the fourth ring on logic + if(!checkRing(count, 4, &input[24])) + return false; + + //If more than four rings + if(count <= 4) + return true; + + //check the fifth ring on logic + if(!checkRing(count, 5, &input[32])) + return false; + + //If more than five rings + if(count <= 5) + return true; + + //check the sixth ring on logic + if(!checkRing(count, 6, &input[40])) + return false; + + return true; } int checkRing(int count, int number, char colour[]) {