+ 1

multidimensional array

void build_pascal(int p[][SIZE], int n); void showmatrix(int p[][SIZE], int n); const int SIZE=100; int main() { int n; cout<<"Enter the number of rows for pascal triangle size: "; cin>>n } void build_pascal(int p[][SIZE], int n) { assert(n>0 && n<SIZE); for(int i=0; i<SIZE; i++) { for(int j=0; j<SIZE; j++) { if(i>n || j>i) { p[i][j] = 0; } else if(j==0 || j==i) { p[i] [j] =1; } else { p[i][j] = p[i-1][j-1]+p[i-1][j]; } } } showmatrix(p,n); } void showmatrix(int p[][SIZE], int n) { for(int i=0; i<SIZE; i++) { for(int j=0; j<SIZE; j++) { cout<<p[i][j]<<"\t"; } cout<<endl; } cout<<endl; } I've done the code up to this and it's not completed .How can I write the matrix and relate the integer to it?

26th Apr 2021, 10:32 AM
Ramisa Fariha
Ramisa Fariha - avatar
8 Respostas
+ 1
26th Apr 2021, 12:07 PM
Ramisa Fariha
Ramisa Fariha - avatar
+ 1
@Martin I' ve fixed those errors..Now what will be the next step?
26th Apr 2021, 2:45 PM
Ramisa Fariha
Ramisa Fariha - avatar
+ 1
Thank you so much
26th Apr 2021, 3:57 PM
Ramisa Fariha
Ramisa Fariha - avatar
0
the question was Write and test a function that creates Pascal’s Triangle in the square matrix that is passed to it. For example, if the two-dimensional array a and the integer 4 were passed to the function, then it would load the following into a: 10000 11000 12100 13310 14641
26th Apr 2021, 10:32 AM
Ramisa Fariha
Ramisa Fariha - avatar