Pascal's triangle

Could I get the logic of this program? Because I don't understand how it works and how it's done. Also why won't it cout itself in the middle? Does anyone have a solution for that? Thanks in advance. :D

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for (int y = 0; y < n; y++)
{
int c = 1;
for (int x = 0; x<=y; x++)
{
cout << c << " ";
c=c*(y-x)/(x+1);
}
cout<<endl;
}
cout<<endl;
return 0;
    }
Topic archived. No new replies allowed.