how to create this program?

the value of C(k,n) are known as the binomial coeficient and can be arranged in triangle that was known as pascal triangle.

i was been asked to create a program that can display rows up to n=9 using print array function.

C(k,n) = C(k-1,n-1) + C(k,n-1)

how should i start?
1
2
3
4
5
6
7
8
9
10
11
12
int C[11][11];
int n,k;
//initialize the array to 0. Some compilers already do this, but it's nice to make sure
for (n=0;n<11;n++)
{
  C[n][0]=1;
  for(k=0;k<11;k++)
    C[n][k]=0;
}
for (n=1;n<11;n++)
  for(k=1;k<=11;k++)
    C[n][k]=C[n-1][k-1]+C[n-1][k];


I leave the printing up to you.
ats15: you're cheating with your dp. :p
owh.. thats all the code? thanks... ill try it.. :) and try to learn it. thanks again..
Topic archived. No new replies allowed.