I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » C/C++ »

trowa0830\′s Photo
5 Dec 07, 4:40PM
#include<stdio.h>
#include<conio.h>
void main()
{
	int a[10][10];
	int i,j,c,n;
 
	clrscr();
 
	printf("enter how many line do you want: ");
	scanf("%d",&n);
 
	a[1] [1]=1;
	printf("%39d ",a[1][1]);
 
	a[2][1]=1;a[2][2]=2;a[2][3]=1;
 
	printf("\n%37d %d %d ",a[2][1],a[2][2],a[2][3]);
	for(i=3;i<=n;i++)
	{
		a[i][1]=1;
		printf("\n%36d ",a[i][1]);
 
		j=2;c=3;
		while(j<=i)
		{
			a[i][j]=a[i-1][c-1]+a[i-1][c-2];
			printf("%d ",a[i][j]);
			c=c+1;
			j=j+1;
		}
		a[i][j]=1;
		printf("%d",a[i][j]);
 
	}
	getch();
}
 
 
 
*******************output*********************
enter how many lines you want: 7
 
				1
			      1 2 1
			     1 3 3 1
                                1 4 6 4 1
                                1 5 10 10 5 1
                                1 6 15 20 15 6 1
                                1 7 21 35 35 21 7 1
 
 
i have problems in making the shape a triangle..
Currently you need to be logged in to leave a message.