// 解答2.8 tri.c // Pascalの三角形 #include #include int combi(int x, int r) { if (r==0 || r==x) return 1; return combi(x-1,r-1)+combi(x-1,r); } int main() { int n,d; scanf("%d",&n); if (n<0 || n>30) return 1; for (int x=0;x<=n;x++) { for (int r=x;r>=0;r--) { d = combi(x,r); #ifdef COLOR printf("\x1b[4%cm", d%8+'0'); printf("\x1b[3%cm", (d%8)?'0':'7'); #endif printf("%8d",d); } #ifdef COLOR printf("\x1b[m"); #endif printf("\n"); } return 0; }