打印星星*** php

来源:互联网 发布:软件开发团队协作 编辑:程序博客网 时间:2024/04/30 10:39
<?php/*****************/for($line=1; $line<=5; ++$line){for($pos=1; $pos<=$line; ++$pos){echo '*';}echo '<br>';}/***************************/echo '<hr>';for($line=1; $line<=5; ++$line){for($pos=1, $max=2*$line-1; $pos<=$max; ++$pos){echo '*';}echo '<br>';}/*    *   ***  ***** *****************/echo '<hr>';for($line=1; $line<=5; ++$line){for($pos=1, $max=5-$line; $pos<=$max; ++$pos){echo ' ';}for($pos=1, $max=2*$line-1; $pos<=$max; ++$pos){echo '*';}echo '<br>';}/*    *   * *  *   * *     **       **/echo '<hr>';for($line=1; $line<=5; ++$line){for($pos=1, $max=5-$line; $pos<=$max; ++$pos){echo ' ';}for($pos=1, $max=2*$line-1; $pos<=$max; ++$pos){if($pos==1 || $pos==$max){echo '*';}else{echo ' ';}}echo '<br>';}/*    *   * *  *   * *     ***********/echo '<hr>';for($line=1; $line<=5; ++$line){for($pos=1, $max=5-$line; $pos<=$max; ++$pos){echo ' ';}for($pos=1, $max=2*$line-1; $pos<=$max; ++$pos){if($pos==1 || $pos==$max || $line==5){echo '*';}else{echo ' ';}}echo '<br>';}/*    *   * *  *   * *     **       * *     *  *   *   * *    **/echo '<hr>';for($line=1; $line<=5; ++$line){for($pos=1, $max=5-$line; $pos<=$max; ++$pos){echo ' ';}for($pos=1, $max=2*$line-1; $pos<=$max; ++$pos){if($pos==1 || $pos==$max){echo '*';}else{echo ' ';}}echo '<br>';}for($line=4; $line>=1; --$line){for($pos=5-$line; $pos>=1; --$pos){echo ' ';}for($pos=1, $max=2*$line-1; $pos<=$max; ++$pos){if($pos==1 || $pos==$max){echo '*';}else{echo ' ';}}echo '<br>';}

0 0
原创粉丝点击