您的位置:首页 > 其它

九九乘法表

2010-05-05 22:00 155 查看
呵呵,非常简单,大家权当复习~~~

算法一:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>九九乘法表</title>
</head>
<body>
<?php
$a=1;
$b=1;
echo '<table border="0" cellpadding="4" cellspacing="1" bgcolor="#FFFFFF">';
while($a<=9)
{
echo '<tr>';
while($b<=$a)
{
echo '<td bgcolor="#FFFFFF"> </td>';
$c=$a*$b;
echo '<td bgcolor="#FFFFFF">'."{$a}*{$b}={$c} ".'</td>';
$b++;
}
echo"<br>";
echo "</tr>";
$b=1;
$a++;

}
echo '</table>';
?>
</body>
</html>


算法二:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>九九乘法表</title>
</head>
<body>
<?php
echo '<table border="0" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">';
for($i = 1; $i <= 9; $i++) {
echo '<tr>';
for ($k = 1; $k <= (9 - $i); $k++) {
echo '<td bgcolor="#FFFFFF"> </td>';
}
for($j = 1; $j <= $i; $j++) {
echo '<td bgcolor="#FFFFFF">' . $i . '*' . $j . '=' . $i * $j . '</td>';
}
echo "</tr>";
}
echo '</table>';
?>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: