Home > Programacion I > Triangulo de Pascal

Triangulo de Pascal

/* Este programa se encuentra en lenguaje C */

#include <stdio.h>
#include <stdlib.h>

/* —o — o —o — o —o — o —o — o —o — o — */

int factorial(int a)
{ if(a == 0 || a == 1)
return 1;

int i, f;
f = 2;
for(i = 3; i <= a; i++)
{ f = f * i; }

return f;
}

/* —o — o —o — o —o — o —o — o —o — o — */

int main(int argc, char *argv[])
{
int h;
printf(“Teclee el numero de lineas para el triangulo de pascal:\t”);
scanf(“%d”,&h);
printf(“\n”);
//printf(“%d\n”,factorial(h));

int p,n,k,j;
j = h;
for(n = 0; n < h; n++)
{for(k = 0; k < j; k++)
printf(“\t”);
for(p = 0; p <= n; p++)
{printf(“%d\t\t”,(factorial(n)/(factorial(p)*factorial(n-p))));}
printf(“\n”);
j–;}
printf(“\n”);

//system(“PAUSE”);
return 0;
}

Categories: Programacion I
  1. sdfsafsdafsdafdsa
    October 3, 2007 at 6:03 pm

    gracias conchas de su madre

  2. Maxi
    August 5, 2009 at 5:59 pm

    Excelente, tengo que rendir un parcial en dos dias me viene buenisimo este programa. Gracias!!!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: