What is the realization method of Java Yang Hui Triangle?
This article mainly explains "what is the realization method of Java Yang Hui Triangle". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the realization method of Java Yang Hui Triangle".
1 do not want to use multi-dimensional array addition, do not want to burn the brain, all understand that the value of I in each layer of Yang Hui Triangle is the sum of m [I] + m [ionization 1] determined by the upper layer.
2 the first element needs special treatment. We can add an element whose number is 0 in the header of each layer.
Func generate (numRows int) [] [] int {var res [] [] int if numRows==0 {return res} res = append (res, [] int {1}) for iride