From 48f66f30421193dbbf10ac8890906d3fa2187372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?r=3Dcos=284=CE=B8=29?= Date: Mon, 1 May 2023 14:41:31 -0500 Subject: [PATCH] Reto mouredev#16 -C++ --- .../c++/OlvadisHernandezLedesma.cpp | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Retos/Reto #16 - LA ESCALERA [Media]/c++/OlvadisHernandezLedesma.cpp diff --git a/Retos/Reto #16 - LA ESCALERA [Media]/c++/OlvadisHernandezLedesma.cpp b/Retos/Reto #16 - LA ESCALERA [Media]/c++/OlvadisHernandezLedesma.cpp new file mode 100644 index 0000000000..c220799985 --- /dev/null +++ b/Retos/Reto #16 - LA ESCALERA [Media]/c++/OlvadisHernandezLedesma.cpp @@ -0,0 +1,85 @@ +#include +#include +#include +using std::string; +using std::cout; +using std::endl; +using std::setw; +using std::cin; + +void drawLadder(int n); +void ladderpositiv(int n); +void ladderNegativ(int n); + +int main() { + int escalon; + do { + cout << "Ingrese el numero de escalones: "; + cin >> escalon; + + if (cin.fail() || cin.eof()) { + break; + } + + drawLadder(escalon); + } while (escalon); + + return 0; +} + +void ladderNegativ(int n){ + n=n*-1; + string parte1="_", parte2="|_"; + for(int i=1; i<=n; i++){ + if(i==1) { + cout<=1; i--){ + if(i==n) { + for(int j=1; j<=i; j++){ + cout<<" "; + } + cout<0) { + ladderPositiv(n); + }else if(n<0){ + ladderNegativ(n); + }else{ + cout<<"__"<