用php输出
1
121
12321
1234321
12321
121
1
<?php
$max = isset($_GET['t']) ? $_GET['t'] : 4;
$row = 1;
$row_break = true;
$str='';
while (true) {
$b = true;
$i = 1;
while (true) {
$str.=$i;
if ($i >= $row)
$b = false;
$b ? $i++ : $i--;
if (!$i){
echo $str. '<br />';
break;
}
}
if ($row >= $max)
$row_break = false;
$row_break ? $row++ : $row--;
$str='';
if (!$row)
break;
}
<?php
$max = isset($_GET['t'])&& is_numeric($_GET['t']) ? $_GET['t'] : 4;
$current_row=$max-1;
while (true) {
$row=$max-abs($current_row--);
$col=$row-1;
$str='';
while (true) {
$str.=$row-abs($col--);
if ($col== -$row){
echo $str. '<br />';
break;
}
}
if ($current_row == -$max)
break;
}
for ($index = 1; $index < 5; $index++) {
for ($indexl = 1; $indexl <= $index; $indexl++) {
echo $indexl;
}
for ($indexl = $index-1; $indexl >0 ; $indexl--) {
echo $indexl;
}
echo '<br>';
}
for ($index = [color=#FF0000]3[/color]; $index > 0; $index--) {
for ($indexl = 1; $indexl <= $index; $indexl++) {
echo $indexl;
}
for ($indexl = $index-1; $indexl >0 ; $indexl--) {
echo $indexl;
}
echo '<br>';
}
$sum = 5;
for($i=1; $i<=$sum; $i++) {
for($k=1; $k<=$sum; $k++) {
echo $k;
if($k == $i) break;
}
for($k=$i-1; $k>=1; $k--) {
if($i == $k) break;
echo $k;
}
echo '<br/>';
}
$len = 9;
for($i=1,$n=2*$len;$i<$n;++$i){
$arr[] = $i == 1 || $i == $n-1 ? '1' : join('',range(1, $len-abs($i-$len))) . join('',range($len-1-abs($i-$len), 1));
}
echo join("\n", $arr);
<?php
$num=9;
for($i=1;$i<$num*2;$i++){
$temm=$num-abs($num-$i);
for($j=1;$j<2*$temm;$j++) printf($temm-abs($temm-$j));
printf("<br />");
}
?>