------------------------------------------------------------------------------------------------------
Print out the Yang Hui Triangle, which can be used as an entrance to thought according to one of its properties: the number of J in line I is equal to the j-1 bit of line i-1 plus the number of j digits, i.e. a[i][j]=a[i-1][j-1]+a[i-1][j].
------------------------------------------------------------------------------------------------------
The C language code is as follows:
# include <stdio.h># include <stdlib.h># include <string.h>int main () { int arr[10][10]={{1}}; int line, row,space; for (line = 0; line < 10; line++) { for (row = 0; row <=line; row++) { if (LINE&NBSP;<&NBSP;2) //first two behaviors 1 { arr[line][row] = arr[0][0]; } else if (row == 0 | | row == line) //element is 1 { arr[line][row] = arr[0 ][0]; } else //Use property Assignment { arr[line][row] = (arr[line - 1][row - 1] + arr[line - 1][row]); } } } for (line = 0; line < 10; line++) //Output { for (row = 0; row <= line; row++) { printf ("%3d ", arr[line][row]); } printf ("\ n"); } system (" Pause "); return 0;}
----------------------------------------------------------------------------------------
little knowledge of dry goods: 1. Right-shift operations with signed values are not portable.
2. The value of the shift operation cannot be negative.
3. The order of evaluation of an expression is partly determined by the precedence and binding of the operators it contains (priority
Greater than the binding); Similarly, the operands of some expressions may need to be converted to other types during evaluation,
("Implicit type Conversions" and "Arithmetic Conversions").
----------------------------------------------------------------------------------------
This article is from the "Nobody" blog, please be sure to keep this source http://814193594.blog.51cto.com/10729329/1702895
Print 10 rows Yang Hui triangle