CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*This code is #3 on trending list*/
/*This code is #1 on CPP trending list*/
#include<iostream>
using namespace std;
int main()
{
int rows;
cout << "Enter the number of rows : ";
cin >> rows;
cout << endl;
for (int i = 0; i < rows; i++)
{
int val = 1;
for (int j = 1; j < (rows - i); j++)
{
cout << " ";
}
for (int k = 0; k <= i; k++)
{
cout << " " << val;
val = val * (i - k) / (k + 1);
}
cout << endl << endl;
}
cout << endl;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run