《正三角》《倒三角》
阿新 • • 發佈:2019-01-23
<?php
header("content-type:text/html;charset=utf-8");
/**
* 九九乘法表
*/
/**
* 正三角
* @var integer
*/
for($i=1;$i<=9;$i++){
for($j=1;$j<=$i;$j++){
echo $j."*".$i;
echo "   ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現正三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu($i)
{
if($i=='1'){
echo '1'."*".'1'. '=' .'1';
echo "<br>";
}else{
jiujiu($i-1);
for($j=1;$j<=$i;$j++){
echo $j."*".$i;
echo "    ";
}
echo "<br>";
}
}
echo jiujiu(9);
echo "<-------------------------------------------------------------------->";
/**
* 倒三角
* @var integer
*/
for($i=1;$i<10;$i++){
for($j=9;$j>=$i;$j--){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現倒三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu1($i)
{
if($i>10){
return;
}
for($j=9;$j>=$i;$j--){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
jiujiu1($i+1);
}
jiujiu1(1);
/******************************************************************************/
echo "<-------------------------------------------------------------------->";
echo "<br>";
<?php
header("content-type:text/html;charset=utf-8");
/**
* 九九乘法表
*/
/**
* 正三角
* @var integer
*/
for($i=1;$i<=9;$i++){
for($j=1;$j<=$i;$j++){
echo $j."*".$i;
echo "   ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現正三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu($i)
{
if($i=='1'){
echo '1'."*".'1'. '=' .'1';
echo "<br>";
}else{
jiujiu($i-1);
for($j=1;$j<=$i;$j++){
echo $j."*".$i;
echo "    ";
}
echo "<br>";
}
}
echo jiujiu(9);
echo "<-------------------------------------------------------------------->";
echo "<br>";
/******************************************************************************/
/**
* 倒三角
* @var integer
*/
for($i=1;$i<10;$i++){
for($j=9;$j>=$i;$j--){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現倒三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu1($i)
{
if($i>10){
return;
}
for($j=9;$j>=$i;$j--){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
jiujiu1($i+1);
}
jiujiu1(1);
/******************************************************************************/
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* for迴圈倒三角
* @var integer
*/
for($i=1;$i<=9;$i++){
for($j=$i;$j<=9;$j++){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現倒三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu2($i)
{
if($i>10){
return;
}
for($j=$i;$j<=9;$j++){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
jiujiu2($i+1);
}
jiujiu2(1);
/**
* for迴圈倒三角
* @var integer
*/
for($i=1;$i<=9;$i++){
for($j=$i;$j<=9;$j++){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現倒三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu2($i)
{
if($i>10){
return;
}
for($j=$i;$j<=9;$j++){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
jiujiu2($i+1);
}
header("content-type:text/html;charset=utf-8");
/**
* 九九乘法表
*/
/**
* 正三角
* @var integer
*/
for($i=1;$i<=9;$i++){
for($j=1;$j<=$i;$j++){
echo $j."*".$i;
echo "   ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現正三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu($i)
{
if($i=='1'){
echo '1'."*".'1'. '=' .'1';
echo "<br>";
}else{
jiujiu($i-1);
for($j=1;$j<=$i;$j++){
echo $j."*".$i;
echo "    ";
}
echo "<br>";
}
}
echo jiujiu(9);
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 倒三角
* @var integer
*/
for($i=1;$i<10;$i++){
for($j=9;$j>=$i;$j--){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現倒三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu1($i)
{
if($i>10){
return;
}
for($j=9;$j>=$i;$j--){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
jiujiu1($i+1);
}
jiujiu1(1);
/******************************************************************************/
echo "<-------------------------------------------------------------------->";
echo "<br>";
<?php
header("content-type:text/html;charset=utf-8");
/**
* 九九乘法表
*/
/**
* 正三角
* @var integer
*/
for($i=1;$i<=9;$i++){
for($j=1;$j<=$i;$j++){
echo $j."*".$i;
echo "   ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現正三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu($i)
{
if($i=='1'){
echo '1'."*".'1'. '=' .'1';
echo "<br>";
}else{
jiujiu($i-1);
for($j=1;$j<=$i;$j++){
echo $j."*".$i;
echo "    ";
}
echo "<br>";
}
}
echo jiujiu(9);
echo "<-------------------------------------------------------------------->";
echo "<br>";
/******************************************************************************/
/**
* 倒三角
* @var integer
*/
for($i=1;$i<10;$i++){
for($j=9;$j>=$i;$j--){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現倒三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu1($i)
{
if($i>10){
return;
}
for($j=9;$j>=$i;$j--){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
jiujiu1($i+1);
}
jiujiu1(1);
/******************************************************************************/
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* for迴圈倒三角
* @var integer
*/
for($i=1;$i<=9;$i++){
for($j=$i;$j<=9;$j++){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現倒三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu2($i)
{
if($i>10){
return;
}
for($j=$i;$j<=9;$j++){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
jiujiu2($i+1);
}
jiujiu2(1);
/**
* for迴圈倒三角
* @var integer
*/
for($i=1;$i<=9;$i++){
for($j=$i;$j<=9;$j++){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
}
echo "<-------------------------------------------------------------------->";
echo "<br>";
/**
* 遞迴實現倒三角
* @param [type] $i [description]
* @return [type] [description]
*/
function jiujiu2($i)
{
if($i>10){
return;
}
for($j=$i;$j<=9;$j++){
echo $i."*".$j;
echo "    ";
}
echo "<br>";
jiujiu2($i+1);
}
jiujiu2(1);