<!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>输出3+杨辉三角形</title>
</head>
<body>
<h3>请输入杨辉三角形的阶数(3+)</h3>
<form method="post">
<input type="text" name="n">
<input type="submit" name="button" value="提交">
</form>
<?php
if(isset($_POST['button'])) //“提交”按钮是否按下
{
$n=$_POST["n"]; //接收文本框n的值
if(!is_numeric($n) or $n<3 or $n<0 or intval($n)!=$n) //判断是否为大于整3的数,或者是小数
{
echo "<script>alert('请输入大于3的整数')</script>";
exit;
}
///以下产生的是所有的第1列和对角线上的1
for($i=0;$i
php输出高阶杨辉三角形
最新推荐文章于 2021-03-28 05:08:48 发布
![](https://img-home.csdnimg.cn/images/20240709112858.png)