phpchen
2019-03-29 11:35:40 +08:00
我已经写出来了
public function ss() {
$n = 3;
$a = pow($n, 3);
$j = 1;
$er = 1;
$er_num = 0;
$er_max_num = $n;
$san = 1;
$san_num = 0;
$san_max_num = $n * $n;
for ($i = 1; $i <= $a; $i++) {
echo "{$j} ";
echo "{$er} ";
echo "{$san} ";
$j++;
$er_num++;
$san_num++;
if ($j > $n) {
$j = 1;
}
if ($er_num >= $er_max_num) {
$er_num = 0;
$er++;
if ($er > $n) {
$er = 1;
}
}
if ($san_num >= $san_max_num) {
$san_num = 0;
$san++;
}
if ($i % $n == 0) {
echo "<hr/>";
}
echo "<br/>";
}
}