Answer to Question #4573 in C++ for Yuri
2011-10-11T11:24:15-04:00
Create a program that will output below:
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
1 8 29 56 70 56 29 8 1
1 9 37 85 126 126 85 37 9 1
1 10 45 112 211 252 211 112 45 10 1
pls use only any of the following: array, loop structure or decision structure
thanks :)
1
2011-10-13T08:10:12-0400
#include "StdAfx.h" #include <iostream> using namespace std; double Cnk(int N,int K) { & double Sum = 1; & for (int i = 1; i <= K; i++) & Sum*=(N-i+1)/float(i); & return Sum; } int main() { int n = 10; & //cout<<"enter dimention "; & //cin>>n; for (int j = 0; j <= n; ++j, cout<<endl) & for (int i = 0; i <= j ; ++i) cout<<Cnk(i, j); system("pause"); & return 0; }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments
Leave a comment