#include <iostream>

using namespace std;

int main() {
    int opcion;
    do {
        cout << "\n1. Cuadrado  2. Rectangulo  3. Creciente  4. Decreciente  5. Piramide  6. Salir" << endl;
        cout << "Opcion: ";
        cin >> opcion;
        
        if (opcion >= 1 && opcion <= 5) {
            int tam;
            cout << "Tamano: ";
            cin >> tam;
            
            if (opcion == 1) { // Cuadrado
                for (int i = 0; i < tam; i++) {
                    for (int j = 0; j < tam; j++) cout << "*";
                    cout << endl;
                }
            } else if (opcion == 2) { // Rectángulo (alto y ancho)
                int ancho;
                cout << "Ancho: ";
                cin >> ancho;
                for (int i = 0; i < tam; i++) {
                    for (int j = 0; j < ancho; j++) cout << "*";
                    cout << endl;
                }
            } else if (opcion == 3) { // Triángulo creciente
                for (int i = 1; i <= tam; i++) {
                    for (int j = 1; j <= i; j++) cout << "*";
                    cout << endl;
                }
            } else if (opcion == 4) { // Triángulo decreciente
                for (int i = tam; i >= 1; i--) {
                    for (int j = 1; j <= i; j++) cout << "*";
                    cout << endl;
                }
            } else if (opcion == 5) { // Pirámide centrada
                for (int i = 1; i <= tam; i++) {
                    for (int j = 1; j <= tam - i; j++) cout << " ";
                    for (int k = 1; k <= (2 * i - 1); k++) cout << "*";
                    cout << endl;
                }
            }
        } else if (opcion == 6) {
            cout << "Programa finalizado." << endl;
        } else {
            cout << "Opcion invalida." << endl;
        }
    } while (opcion != 6);
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: