[ create a new paste ] login | about

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

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

int main()
{
    int total_lineas = 10, nlinea = 1, 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 < (nlinea - 1))
            {
                printf(" ");
                nesp++;
            }

            while (nast < ((total_lineas * 2) - (nesp * 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
Piramide de asteriscos:
Indique cuantos pisos desea que tenga la piramide (Maximo 40 pisos): *******************
 *****************
  ***************
   *************
    ***********
     *********
      *******
       *****
        ***
         *


Create a new paste based on this one


Comments: