Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Is there any way for PHP to get 10 lines of Yang Hui triangle?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to get 10 lines of Yang Hui triangle in PHP. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Algorithm analysis: there is an array of I rows and j columns (j less than or equal to I)

1, double for loop, the first layer loop, traversing the array row I; the second layer loop, traversing the array column j. And the column j value of the array is less than or equal to the row I value of the array.

2. If statement is used in the body of the second layer loop to judge, and the value is $array [I] [j] = 1 when jroom1 or iRecij is used.

At other times, $array [I] [j] = $array [imur1] [jmur1] + $array [iMur1] [j]

Example

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report