Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int TinhGiaiThua(int n)
- {
- int f;
- for (f = 1; n > 1; n--)
- {
- f *= n;
- }
- return f;
- }
- int TinhSoPascal(int a, int b)
- {
- int z = 0;
- z = TinhGiaiThua(a) / (TinhGiaiThua(b) * TinhGiaiThua(a - b));
- return z;
- }
- int main()
- {
- int n;
- cin >> n;
- for (int i = 0; i <n; i++)
- {
- for (int j = 0; j < (n - 1) - i; j++)
- {
- cout << " ";
- }
- for (int j = 0; j <= i; j++)
- {
- cout << TinhSoPascal(i, j) << " ";
- }
- cout << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement