View Single Post
  #8 (permalink)  
Old 12-05-2007, 01:03 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,122
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
It's better if you can use the CODE tag...

Code:
	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..
so that I don't need to download stuff lol... I'll look over ur code, this is a logical problem

HINT: there's sequence of space on the triangle, print that one first, then you print the number

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to HelloWorld For This Useful Post:
TeraTask (12-05-2007)