From f690a5aab351dcf7b8da126b5f776682f89fa5d1 Mon Sep 17 00:00:00 2001 From: Jason Peters Date: Sat, 3 Feb 2024 20:47:35 +0100 Subject: [PATCH] =?UTF-8?q?Funktion=20um=20Array=20des=20Dreiecks=20mit=20?= =?UTF-8?q?X=20zu=20bef=C3=BCllen?= 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 9638174..00b8353 100644 --- a/src/main/c/Jason/ASCII_art.c +++ b/src/main/c/Jason/ASCII_art.c @@ -65,6 +65,9 @@ void dreieck(){ } while(hoehe < 2); int arraygroesse = berechnungDerDreieckArraygroesse(hoehe); + char dreieck[arraygroesse]; + befuellenDesDreiecksMitX(dreieck, arraygroesse); + @@ -249,3 +252,15 @@ int berechnungDerDreieckArraygroesse(int zeilen){ return arraygroesseInklusiveEinerreiheOhneXOderBackslashN; } + +void befuellenDesDreiecksMitX(char arr[], int goresse){ + + for(int i = 0; i < goresse; i++){ + + arr[i] = 'X'; + + } + arr[goresse-1] = '\0'; + +} + diff --git a/src/main/c/Jason/ASCII_art.h b/src/main/c/Jason/ASCII_art.h index 29b4eee..46d2bcc 100644 --- a/src/main/c/Jason/ASCII_art.h +++ b/src/main/c/Jason/ASCII_art.h @@ -22,5 +22,6 @@ void stammAnRichtigerStelleEinsetzen(char[], int); void dreieck(); void dreieckWillkommensnachricht(); int berechnungDerDreieckArraygroesse(int); +void befuellenDesDreiecksMitX(char[], int); #endif