Basic php algorithms (represented by *) and algorithm pyramid

Source: Internet
Author: User

Basic php algorithms (represented by *) and algorithm pyramid
*
***
*****
*******
*********

***********

The php code is as follows:

<? Phpfor ($ I = 1; $ I <= 6; $ I ++) {for ($ z = 5; $ z >=$ I; $ z --) {echo "" ;}for ($ j = 1; $ j <= 2 * $ I-1; $ j ++) {echo "*";} echo "<br/> ";}


Write a program in php and display the following digital pyramid.

<? Php
$ Tier = 5; $ a = 3; $ B = 4;
While ($ tier --){
For ($ temp = 0; $ temp <= $ a; $ temp ++ ){
Echo '';
}
For ($ temp = $ a + 1; $ temp <= $ B; $ temp ++ ){
Echo '*';
}
$ A --; $ B ++;
Echo '<br/> ';
}
?>
 
How can I use PHP to create a pyramid chart?

You need to know how to draw a pyramid.
0 indicates white, and 1 indicates black. In fact, php controls the number of zeros in each row and the number of followed ones. Right?
It is much easier to use php to learn how to draw images.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.