>The following link may be helpful
I doubt it, unless the OP is still having trouble with this assignment three years later. :icon_rolleyes:
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
It's still a three year old thread. Though it is mildly humorous that people will bump ancient threads with bad advice and/or bad code. However, since this thread is so old, and because I'm bored, I'll reject your code and substitute my own:
#include <iostream>
int factorial ( int n, int k )
{
int result = 1;
while ( k-- > 0 )
result *= n--;
return result;
}
int pascal_triangle ( int n, int k )
{
return factorial ( n, k ) / factorial ( k, k );
}
int main()
{
for ( int i = 0; i < 9; i++ ) {
for ( int j = 0; j <= i; j++ )
std::cout<< pascal_triangle ( i, j ) <<' ';
std::cout<<'\n';
}
}
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401