Generation

generate functionWed, 10 May 2023

escribir un programa en c++ que solicite un numero entero positivo no mayor que 9 y nos permita imprimir un triangulo como el mostrado Ejemplo: Ingrese n = 4 1 1 3 1 3 5 1 3 5 7

int i, j; // Input number of rows cout << "Enter number of rows: "; cin >> rows; // Iterate through rows for(i=1; i<=rows; i++) { // Print leading spaces for(j=i; j<rows; j++) { cout << " "; } // Print numbers for(j=1; j<=i; j++) { cout << j << " "; } // Move to next line/row cout << endl; }

Questions about programming?Chat with your personal AI assistant