In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "php how to print a side length of N solid and hollow diamond", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "php how to print a side length of N solid and hollow diamond" this article.
This paper describes the method of printing a solid and hollow diamond with a side length of N by php. Share it with you for your reference. The specific analysis is as follows:
Solid diamond calculation method:
$n: side length
$I: current line, starting with 0
$rows: total number of lines
Upper part
Number of leading spaces = $n-$i-1
Number of characters = $iTunes 2 characters 1
Lower part
Number of leading spaces = $i-$n+1
Number of characters = ($rows-$i) * 2-1
Using str_pad can reduce cycles such as for/while
/ * * print solid diamond * @ param int $n side length. Default is 5 * @ param String $s. Default is * * @ return String * / function solidDiamond ($str =''). / / calculate the total number of lines $rows = $nasty 2-1; / / cycle the * for ($iS0; $I) of each line
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.