```
#include <iostream>
#include <stdlib.h>
using namespace std;
string Separator(" ");
float factorial (float n)
{
if (n == 0.0f)
return 1.0f;
else if (n != 1.0f)
return n*factorial (n-1.0f);
else
return n;
}
float combination (float n,float r)
{
return factorial(r)/((factorial(r-n)*factorial(n)));
}
void printRow(float r)
{
for (float i=0.0f; i<=r; i+=1.0f){
cout << combination (i,r) << Separator;
}
}
void printRows(float r)
{
for (float j=0.0f; j<r; j+=1.0f){
printRow(j);
cout << endl;
}
}
int main(int argc, char** argv)
{
float nRows = 10.0f;
cout << "Hello, This is me Pascal. I'll give you ";
if (argv [1] == 0)
cout << "10 Lines of my famous triangle";
else if (atof (argv [1]) <= 0.0f)
cout << "10 Lines of my famous triangle";
else {
nRows = atof(argv [1]);
cout << argv [1] << (nRows > 1? " Lines " : " Line ") << "of my famous triangle.\n";
}
printRows(nRows);
}
```

Recommended Topics