From 2c6bf4e0523d6fad437171958df340bfa5ecab18 Mon Sep 17 00:00:00 2001 From: Jason Peters Date: Wed, 31 Jan 2024 13:57:47 +0100 Subject: [PATCH] =?UTF-8?q?Anlegen=20des=20Arrays=20und=20bef=C3=BCllen=20?= =?UTF-8?q?davon=20mit=20X?= 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, 13 insertions(+), 3 deletions(-) diff --git a/src/main/c/Jason/ASCII_art.c b/src/main/c/Jason/ASCII_art.c index 2ed764b..d13f3a3 100644 --- a/src/main/c/Jason/ASCII_art.c +++ b/src/main/c/Jason/ASCII_art.c @@ -1,6 +1,5 @@ #include "ASCII_art.h" #include -#include int ASCII_Art(){ @@ -19,7 +18,9 @@ void quadrat(){ int groesse; scanf("%d", &groesse); int arraySize = berechnungDerLaengeDesQuadratArrays(groesse); - + char Quadrat[arraySize]; + befuellenDesArraysMitX(Quadrat, arraySize); + } @@ -34,7 +35,7 @@ return 0; void auswahlDerArt(int pick){ switch (pick) { case (1): - quadrat(); + return quadrat(); break; case (2): @@ -58,4 +59,12 @@ int berechnungDerLaengeDesQuadratArrays(int anzahlDerX){ // länge des Arrays für ein Quadrat return ArraygroesseDesQuadrats; +} + +void befuellenDesArraysMitX(char quadraT[], int laenge){ + + for (int i = 0; i < laenge; i++){ + quadraT[i] = 'X'; + } + 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 97091a3..cdb89dd 100644 --- a/src/main/c/Jason/ASCII_art.h +++ b/src/main/c/Jason/ASCII_art.h @@ -7,6 +7,7 @@ void auswahlDerArt(int); void quadrat(); int frageNachGroesse(); int berechnungDerLaengeDesQuadratArrays(int); +void befuellenDesArraysMitX(char[], int);