From c415495cb5a38876d2a6ee995073a700252c0d19 Mon Sep 17 00:00:00 2001 From: Jason Peters Date: Wed, 31 Jan 2024 14:25:28 +0100 Subject: [PATCH] =?UTF-8?q?Bef=C3=BCllen=20des=20Arrays=20an=20jeder=202.?= =?UTF-8?q?=20Stelle=20mit=20Leerzeichen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Jason/ASCII_art.c | 15 +++++++++++++++ src/main/c/Jason/ASCII_art.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/main/c/Jason/ASCII_art.c b/src/main/c/Jason/ASCII_art.c index d13f3a3..d557b88 100644 --- a/src/main/c/Jason/ASCII_art.c +++ b/src/main/c/Jason/ASCII_art.c @@ -20,6 +20,8 @@ void quadrat(){ int arraySize = berechnungDerLaengeDesQuadratArrays(groesse); char Quadrat[arraySize]; befuellenDesArraysMitX(Quadrat, arraySize); + befuelleArrayMitLeerzeichen(Quadrat, arraySize); + } @@ -67,4 +69,17 @@ void befuellenDesArraysMitX(char quadraT[], int laenge){ quadraT[i] = 'X'; } quadraT[laenge-1] = '\0'; + +} + +void befuelleArrayMitLeerzeichen(char quadraT[], int laenge){ + + + for (int i = 0; i < laenge; i++){ + if(i % 2 != 0){ + quadraT[i] = ' '; + } + + } + quadraT[laenge-1] = '\0'; } \ No newline at end of file diff --git a/src/main/c/Jason/ASCII_art.h b/src/main/c/Jason/ASCII_art.h index cdb89dd..61dca6a 100644 --- a/src/main/c/Jason/ASCII_art.h +++ b/src/main/c/Jason/ASCII_art.h @@ -8,6 +8,7 @@ void quadrat(); int frageNachGroesse(); int berechnungDerLaengeDesQuadratArrays(int); void befuellenDesArraysMitX(char[], int); +void befuelleArrayMitLeerzeichen(char[],int);