* * Use a two-dimensional array to print a 10-line Yang Hui's triangle.
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 ten
5 1
....
"Hint"
1. There are 1 elements in the first row and N elements 2 in the nth row. The
first and last elements of each row are 1
3. Starts with the third row, for elements that are not the first element and the last element.
YANGHUI[I][J] = Yanghui[i-1][j-1] + yanghui[i-1][j];
*/Public
class Test_03yanghui {public
static void Main (string[] args) {
//1. Create a two-dimensional array of the specified format
int[][] Yanghui = new int[10][];
for (int i = 0; i < yanghui.length i++) {
Yanghui[i] = new int[i+1];
2. Assign a value for a two-dimensional array for
(int i = 0; i < yanghui.length i++) {
yanghui[i][0] = yanghui[i][i] = 1;
if (i > 1) {for
(int j = 1; j < Yanghui[i].length-1; J +) {
yanghui[i][j] = yanghui[i-1][j-1] + Yan GHUI[I-1][J];
}} 3. Traversal two-dimensional array for
(int i = 0; i < yanghui.length i++) {for
(int j = 0; J < Yanghui[i].length; J +) {
S Ystem.out.print (Yanghui[i][j] + "");
}
System.out.println ();}}