#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int create_matrix(int* matrix[], int row, int column, int size);
int create_pascals(int a, int b);
int main()
{
//variable declaration
int size;
int* row = &size;
int* column = &size;
//output to the screen
cout << " Please enter the size you want for your Pascal Triangle(# must be lesser than 10!!!): " << endl;
cin >> size;
//incase of number greater than 10 the program will terminate
if(size>10)
{
cout<< " program will now terminate!!! thank you for using this program" << endl;
exit(1);
}
//real stuff begins at this line
else
{
//matrix declaration//
int * *matrix= new int*[*row];
for(int i=0; i<*row; i++)
{
matrix[i] = new int[*column];
}
//matrix declaration//
//creating left blanks
for(int row=0; row<size; row++)
{
for (int column=1; column<size-row; column++)
{
cout.width(2);
cout << "D";
}
//introducing to fill the value
for (int column=0; column<=row; column++)
{
cout.width(4);
cout << create_pascals(row, column);
}
cout << endl;
}
//deletion
for(int i=0; i<*row; i++)
delete[] matrix[i];
delete[]matrix;
return 0;
}
}
int create_pascals(int a, int b)
{
??????????????????????????????????????????????????????????????????????????????????
int cons = 1, row;
if (a< 0|| b<0|| b>a)
{
cout << " error!!! the program will now terminate." << endl;
exit(1);
}
????????????????????????????????????????????????????????????????????????????????
else
{
?????????????????????????????????????????????????????????????????????????????
for (row=1; row<=b;row++, a--)
{
cons = cons*a/row;
}
return cons;
}
????????????????????????????????????????????????????????????????????????????
}
i am trying to come up with code to make a pascal triangle using dynamic array this is what i have come up with so far. i need some explaination about some part of the code... thanks the code that i have question with is encircled with [???????], also can you tell me if my code is the right or wrong because i need it to be made with matrix(dymanic matrix) that why i declare it at a line.
thanks guys