作业代码:
实例
<?php echo "<h3>while do while 练习</h3><h4>打印九九乘法表</h4><hr />"; $a=$b=1; while($a<10){ echo "<p>{$a}X{$b}=".$a*$b." "; while($b<$a){ $b++; echo "{$a}X{$b}=".$a*$b." "; } echo "</p>"; $b=1; $a++; } echo "<hr />"; $a=$b=1; do{ echo "<p>{$a}X{$b}=".$a*$b." "; while($b<$a){ $b++; echo "{$a}X{$b}=".$a*$b." "; } echo "</p>"; $b=1; $a++; }while($a<10); echo "<hr />"; echo "<h3>数组练习 模拟队列、栈</h3><hr />"; $namelist=['张三','李四','王五','赵六','周七']; //入栈 array_push($namelist, '吴八'); print_r($namelist); echo "<br />"; //出栈 array_pop($namelist); print_r($namelist); echo "<br />"; //入队首 array_unshift($namelist,"钱一","孙二"); print_r($namelist); echo "<br />"; //入队尾 array_push($namelist,"郑九","冯十"); print_r($namelist); echo "<br />"; //出队首 array_shift($namelist); print_r($namelist); echo "<br />"; //出队尾 array_pop($namelist); print_r($namelist); echo "<br />";
运行实例 »
点击 "运行实例" 按钮查看在线实例
二、运行结果