[ create a new paste ] login | about

Link: http://codepad.org/NMvMY8EP    [ raw code | output | fork ]

vicenaf - C, pasted on May 19:
#include <stdio.h>
#include <stdlib.h>

int main()
{

    int total_lineas = 10, nlinea = 0, nast = 0, nesp = 0;

    printf ("Piramide de asteriscos:\n");
    printf ("Indique cuantos pisos desea que tenga la piramide (Maximo 40 pisos): ");
    scanf("%d", &total_lineas);

    // inicializo nlinea al numero total de lineas
    nlinea = total_lineas;

    while (nlinea > 0)
    {
            while (nesp < total_lineas - nlinea)
            {
                printf(" ");
                nesp++;
            }
            while (nast < ((nlinea * 2) - 1))
            {
                printf("*");
                nast++;
            }
    nesp = 0;
    nast = 0;
    //resto una linea cada vez
    nlinea--;
    printf("\n");
    }
    return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
Piramide de asteriscos:
Indique cuantos pisos desea que tenga la piramide (Maximo 40 pisos): *******************
 *****************
  ***************
   *************
    ***********
     *********
      *******
       *****
        ***
         *


Create a new paste based on this one


Comments: