+ 1
How to make Pascal triangle in C++
I am trying to make Pascal triangle https://code.sololearn.com/csLzNm1FqqTp/?ref=app
3 Respuestas
+ 13
Here is a good instruction for you, Sushmit.
https://www.programiz.com/cpp-programming/examples/pyramid-pattern
+ 13
#include <iostream>
using namespace std;
int main() {
int n;
cin>>n;
for (int i = 0; i < n; i++)
{
for (int j = 1; j < (n - i); j++)
{
cout << " ";
}
for (int k = 0; k <= i; k++)
{
cout << " " <<"^";
}
cout << endl << endl;
}
cout << endl;
return 0;
}
+ 4
use this algorithm :-
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
for(int j=i;j<=n;j++)
cout<<" ";
for(int k=1;k<=i;k++)
cout<<k;
for(int l=i-1;l>=1;l--)
cout<<l;
cout<<endl;
}