PHP prints Yang Hui's triangle as shown in the picture:
Use PHP programming to generate any row of Yang Hui triangles.
function yanghui($line)
{
echo "
";
for($i=1;$i {
echo "
";
for($j=1;$j {
$yh[$i][1]=1;
if ($i==$j) $yh[$i][$j]=1;
else $yh[$i][$j]=$yh[$i-1][$j-1]+$yh[$i-1][ $j];
echo "
";
echo $yh[$i][$j];
echo "
";
}
echo "
";
}
echo "
";
}
Copy code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn