[ create a new paste ] login | about

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

vicenaf - C, pasted on Aug 10:
#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);

    while (nlinea <= total_lineas)
    {
            while (nesp < total_lineas - nlinea)
            {
                printf(" ");
                nesp++;
            }
            while (nast < ((nlinea * 2) - 1))
            {
                printf("*");
                nast++;
            }
    nesp = 0;
    nast = 0;
    nlinea++;
    printf("\n");
    }
    return 0;
}


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


Create a new paste based on this one


Comments: