zoukankan      html  css  js  c++  java
  • PHP基本语法练习题

    输入10个人的姓名成绩,按从大到小排序打印出来

     1 <?php
     2 ?>
     3 <form action="" method="post">
     4 姓名:<input type="text" name="xm1"  style="50px; height:20px;"/>
     5 成绩:<input type="text" name="cj1"  style="50px; height:20px;"/><br />
     6 姓名:<input type="text" name="xm2"  style="50px; height:20px;"/>
     7 成绩:<input type="text" name="cj2"  style="50px; height:20px;"/><br />
     8 姓名:<input type="text" name="xm3"  style="50px; height:20px;"/>
     9 成绩:<input type="text" name="cj3"  style="50px; height:20px;"/><br />
    10 姓名:<input type="text" name="xm4"  style="50px; height:20px;"/>
    11 成绩:<input type="text" name="cj4"  style="50px; height:20px;"/><br />
    12 姓名:<input type="text" name="xm5"  style="50px; height:20px;"/>
    13 成绩:<input type="text" name="cj5"  style="50px; height:20px;"/><br />
    14 姓名:<input type="text" name="xm6"  style="50px; height:20px;"/>
    15 成绩:<input type="text" name="cj6"  style="50px; height:20px;"/><br />
    16 姓名:<input type="text" name="xm7"  style="50px; height:20px;"/>
    17 成绩:<input type="text" name="cj7"  style="50px; height:20px;"/><br />
    18 姓名:<input type="text" name="xm8"  style="50px; height:20px;"/>
    19 成绩:<input type="text" name="cj8"  style="50px; height:20px;"/><br />
    20 姓名:<input type="text" name="xm9"  style="50px; height:20px;"/>
    21 成绩:<input type="text" name="cj9"  style="50px; height:20px;"/><br />
    22 姓名:<input type="text" name="xm10"  style="50px; height:20px;"/>
    23 成绩:<input type="text" name="cj10"  style="50px; height:20px;"/><br />
    24 
    25 <input type="submit" value="点击排序" />
    26 </form>
    27 <?
    28      //定义数组cj,接收文本框里的成绩;
    29      $cj[0]=$_POST['cj1'];
    30      $cj[1]=$_POST['cj2'];
    31      $cj[2]=$_POST['cj3'];
    32      $cj[3]=$_POST['cj4'];
    33      $cj[4]=$_POST['cj5'];
    34      $cj[5]=$_POST['cj6'];
    35      $cj[6]=$_POST['cj7'];
    36      $cj[7]=$_POST['cj8'];
    37      $cj[8]=$_POST['cj9'];
    38      $cj[9]=$_POST['cj10'];
    39      //定义数组xm,接收文本框里的姓名;
    40      $xm[0]=$_POST['xm1'];
    41      $xm[1]=$_POST['xm2'];
    42      $xm[2]=$_POST['xm3'];
    43      $xm[3]=$_POST['xm4'];
    44      $xm[4]=$_POST['xm5'];
    45      $xm[5]=$_POST['xm6'];
    46      $xm[6]=$_POST['xm7'];
    47      $xm[7]=$_POST['xm8'];
    48      $xm[8]=$_POST['xm9'];
    49      $xm[9]=$_POST['xm10'];
    50      //定义中间变量,进行冒泡排序;
    51      $zhong;
    52      for($i=0;$i<10;$i++)
    53      {
    54          for($j=$i;$j<9;$j++)
    55          {
    56              if($cj[$i]<$cj[$j+1])
    57              {
    58                  $zhong=$cj[$j+1];
    59                  $cj[$j+1]=$cj[$i];
    60                  $cj[$i]=$zhong;
    61              }
    62          }
    63      }
    64      //遍历数组,输出姓名和成绩;
    65      for($k=0;$k<count($cj);$k++)
    66      {
    67          echo"$xm[$k] ";
    68          echo"$cj[$k]<br>";
    69      }
    70 ?>
  • 相关阅读:
    TensorFLow手写字识别深度学习网络分析详解
    使用MSBUILD 构建时出错 error MSB3086: 任务未能使用 SdkToolsPath“”或注册表项“XXX”找到“LC.exe”,请确保已设置 SdkToolsPath。
    解决Win7启动时出现“windows未能启动。原因可能是最近更改了硬件或软件”的问题
    SSH安装篇之——SecureCRT连接(内网和外网)虚拟机中的Linux系统(Ubuntu)
    git push 冲突
    ubuntu快捷键收集
    ubuntu中wine下安装QQ
    ubuntu下安装无线网卡去驱动Qualcomm-Atheros-QCA9377
    spring mvc添加静态资源访问时@Controller无效的解决
    git更新到远程服务器代码
  • 原文地址:https://www.cnblogs.com/Itwonderful/p/5390643.html
Copyright © 2011-2022 走看看