杨辉三角打表

#include<bits/stdc++.h>
using namespace std;
unsigned long long pre[1005][1005];
void init()
{
    pre[0][0]=1;
    for(int i=1;i<=1000;i++){
        for(int j=0;j<=i;j++){
            if(j==0||j==i){
                pre[i][j]=1;
            }
            else{
                pre[i][j]=pre[i-1][j-1]+pre[i-1][j];
            }
        }
    }
}
int main()
{
    init();
    int cnt=0;
    for(int i=0;i<=50;i++){
        printf("%d ",i);
        for(int j=0;j<=i;j++){
            if(pre[i][j]%7==0){
                printf("*");
                cnt++;
            }
            else{
                printf(" ");
            }
        }
        printf("   %d
",cnt);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/ldu-xingjiahui/p/12407406.html