📜  使用 c++ 代码示例的帕斯卡三角形

📅  最后修改于: 2022-03-11 14:44:54.394000             🧑  作者: Mango

代码示例1
#include 
using namespace std;


int fact(int num){
    int factorial = 1;
    for (int i = 2; i <= num; i++)
    {
        factorial = factorial * i;
    }
    return factorial;
}

int main(){
    int n;
    cout << "Enter number of rows: ";
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <=i; j++)
        {
            cout << fact(i) / (fact(j) * fact(i - j)) << " ";
        }
        cout << endl;
    }
    
}