The Yang Hui triangle under java-general Linux technology-Linux programming and kernel information. The following is a detailed description.
The Yang Hui triangle is a triangle number table arranged by numbers. The general format is as follows:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
........................................ ..............
The most essential feature of the Yang Hui triangle is that its two oblique edges are composed of digits 1, while the remaining number is equal to the sum of the two numbers on its shoulders.
In fact, ancient Chinese mathematicians are far ahead in many important mathematical fields. The history of ancient Chinese Mathematics once had its own brilliant chapter, and the discovery of the Yang Hui triangle was a wonderful page.
Yang Hui, Zi qianguang, from Hangzhou in the Northern Song Dynasty. In his book "detailed explanation of Chapter 9 algorithms" in 1261, the author recorded the triangle number table shown above, which is called the "Origin of the practice.
Such a triangle is also frequently used in our Olympics competition. The simplest thing is to ask you to find a rule. We will explain the specific usage in the teaching content.
Public class YangHui
{
Public static void main (String args [])
{
Final int ROW = 5;
Int a [] [] = new int [ROW + 1] [];
For (int I = 0; I <= ROW; I ++)
{
A= New int [I + 1];
}
Yanghui (a, ROW );
}
Static void yanghui (int a [] [], int ROW)
{
For (int I = 0; I <= ROW; I ++)
For (int j = 0; j <=. Length-1; j ++)
{
If (I = 0 | j = 0 | j =. Length-1)
A[J] = 1;
Else[J] = a [I-1] [J-1] + a [I-1] [j];
}
For (int I = 0; I <= ROW; I ++)
{
For (int j = 0; j <=. Length-1; j ++)
System. out. print ([J] + "");
System. out. println ();
}
}
}
Keywords: Yang Hui triangle