<?php
function Yanghui ($lines) {
Echo ' ;//Header insert CSS style
Echo ' <a id=cow> ', $lines, ' </a>';
Echo ' <a id=column> ', ($lines-$lines%2)/2 + ($lines%2), ' </a>‘;//Want to set each table to conform to the same width,
//to get the width of a number that has the largest value
//here we get the position of this number first.。
//Use JS code to get its width, CSS set td width
Echo ' <table > ';//A table put a number
for ($i =1; $i <= $lines; + + $i) {
Echo ' <tr> ';
for ($x =1; $x <= $lines-$i; + + $x)the values of the//Yang Hui triangle have n rows n columns the first number at the top already has a 1
{echo ' <td> </td> ';}//Isosceles triangle to consider the number of spaces left in 1, so here is the $lines-$i;
for ($j =1; $j <= $i; + + $j) {
Echo ' <td id= ', $i, $j, ' > ';id= "11" 1 rows and 1 columns per table, changing with loops
//First column, diagonal
if ($j ==1 | | $j = = $i)
{
Echo$data [$i] [$j] = 1;//Assign value first, then output
}
Else
{
Echo$data [$i] [$j] = $data [$i -1][$j] + $data [$i -1][$j-1];//The value of each number is the sum of two numbers above that number
}
Echo ' </td> ', ' <td> </td> ';//One space at a time per cycle
}
Echo ' </tr> ';
}
Echo ' </table> ';
Echo
' <script type= ' text/javascript ' >
var cow = document.getElementById ("cow"). InnerHTML
var column = document.getElementById ("column"). InnerHTML
var td = document.getElementById (Cow+column)
var width_td = td.offsetwidth
var HD = document.getElementById ("HD")
var stl = document.createelement ("style")
stl.innerhtml = "A{visibility:hidden;} td {Width: "+ width_td +" Px;text-align:center;color:green;} "
Hd.appendchild (STL)
</script> ';
}
Yanghui (a);
php_js_css_html--Yang Hui Triangle