Pascal Triangle
Wait a while, and then pull Pascal triangle~.
First a year ago to print Yang Hui triangle method paste out (simply do not recognize the look, more and more afraid to see their own writing)
C Language implementation:
/*************************************************************** Code writer:eof Code date:2013.05.16 e-mail: [Email protected] Code Description:here is a demo-to-print out the Pascal triangle.******************************************* /#include <stdio.h> #include <stdlib.h>void buildup (int s, int *n), void putout (int s,    int *n); int main () {int row = 0;    int k = 0, m = 0, x = 0, S = 0;    printf ("Please enter the row number");         while (!SCANF ("%d", &s)) {while (GetChar ()! = ' \ n ');    printf ("Please enter again!\n");    } int *n = (int *) malloc ((S + 1) * (S/2) *sizeof (int));        if (!n) {printf ("malloc failed!\n");    return-1;    } buildup (S, n);    Putout (S, N); return 0;}    void buildup (int S, int *n) {int row, K, m, X, Y, a, B;        row = k = m = x = y = a = b = 0;    Initialization for (m = 0; m < (s+1) * (S/2); m++) {n[m] = 0; } for (row = 1; row ≪= S;        row++) {m = ((row* (row-1))/2);    N[M] = 1;        } for (row = 1;row <= S; row++) {m = ((row* (row+1))/2)-1;    N[M] = 1;            }//key method for (k = 2, K <= S-1; k++) {for (row = (3 + k-2); row <= S; row++) {            m = ((row* (row-1))/2)-1 + k;            x = M-row;            y = m-row + 1;            A = ((row* (row+1))/2)-row;            B = ((row* (row+1))/2)-1;            if (M! = a && m! = b) {N[m] = N[x] + n[y];            } else {n[m] = 1;    }}}}void putout (int S, int *n) {int row, blank, rank, num;    row = blank = Rank = num = 0; for (row = 1, row <= S; row++) {if (row = = 1) {for (blank = 1; blank <= (s-row); blank+            +) {printf ("");      }} else {for (blank = 1; blank <= (S-row); blank++)      {printf ("");            }} for (rank = 1; rank <= row; rank++) {printf ("%d", N[num]);            num++;            if (rank = = row) {printf ("\ n");        } printf (""); }    }}
Photo taken on August 14, 2014
Pascal Triangle Pascal Triangle Yang Hui triangle two-term theorem