PHP Basic Grammar Exercises

Source: Internet
Author: User

Enter 10 person's name scores, print from big to small sort

1<?PHP2?>3<form action= "" method= "POST" >4Name: <input type= "text" name= "XM1" style= "width:50px; height:20px; " />5Score: <input type= "text" name= "cj1" style= "width:50px; height:20px; " /><br/>6Name: <input type= "text" name= "xm2" style= "width:50px; height:20px; " />7Score: <input type= "text" name= "CJ2" style= "width:50px; height:20px; " /><br/>8Name: <input type= "text" name= "xm3" style= "width:50px; height:20px; " />9Score: <input type= "text" name= "Cj3" style= "width:50px; height:20px; " /><br/>TenName: <input type= "text" name= "XM4" style= "width:50px; height:20px; " /> OneScore: <input type= "text" name= "Cj4" style= "width:50px; height:20px; " /><br/> AName: <input type= "text" name= "XM5" style= "width:50px; height:20px; " /> -Score: <input type= "text" name= "cj5" style= "width:50px; height:20px; " /><br/> -Name: <input type= "text" name= "XM6" style= "width:50px; height:20px; " /> theScore: <input type= "text" name= "cj6" style= "width:50px; height:20px; " /><br/> -Name: <input type= "text" name= "xm7" style= "width:50px; height:20px; " /> -Score: <input type= "text" name= "CJ7" style= "width:50px; height:20px; " /><br/> -Name: <input type= "text" name= "XM8" style= "width:50px; height:20px; " /> +Score: <input type= "text" name= "Cj8" style= "width:50px; height:20px; " /><br/> -Name: <input type= "text" name= "xm9" style= "width:50px; height:20px; " /> +Score: <input type= "text" name= "Cj9" style= "width:50px; height:20px; " /><br/> AName: <input type= "text" name= "XM10" style= "width:50px; height:20px; " /> atScore: <input type= "text" name= "Cj10" style= "width:50px; height:20px; " /><br/> -  -<input type= "Submit" value= "click to sort"/> -</form> -<? -      //define the array CJ, receive the results in the text box; in      $CJ[0]=$_post[' Cj1 ']; -      $CJ[1]=$_post[' CJ2 ']; to      $CJ[2]=$_post[' Cj3 ']; +      $CJ[3]=$_post[' Cj4 ']; -      $CJ[4]=$_post[' Cj5 ']; the      $CJ[5]=$_post[' Cj6 ']; *      $CJ[6]=$_post[' CJ7 ']; $      $CJ[7]=$_post[' Cj8 '];Panax Notoginseng      $CJ[8]=$_post[' Cj9 ']; -      $CJ[9]=$_post[' Cj10 ']; the      //defines an array of XM, receiving a name in a text box; +      $XM[0]=$_post[' XM1 ']; A      $XM[1]=$_post[' XM2 ']; the      $XM[2]=$_post[' XM3 ']; +      $XM[3]=$_post[' XM4 ']; -      $XM[4]=$_post[' XM5 ']; $      $XM[5]=$_post[' XM6 ']; $      $XM[6]=$_post[' Xm7 ']; -      $XM[7]=$_post[' XM8 ']; -      $XM[8]=$_post[' Xm9 ']; the      $XM[9]=$_post[' XM10 ']; -      //define intermediate variables and bubble sort;Wuyi      $zhong; the       for($i= 0;$i<10;$i++) -      { Wu           for($j=$i;$j<9;$j++) -          { About              if($CJ[$i]<$CJ[$j+1]) $              { -                  $zhong=$CJ[$j+1]; -                  $CJ[$j+1]=$CJ[$i]; -                  $CJ[$i]=$zhong; A              } +          } the      } -      //iterate through the array, outputting names and scores; $       for($k= 0;$k<Count($CJ);$k++) the      { the          Echo"$XM[$k] "; the          Echo"$CJ[$k]<br> "; the      } -?>

PHP Basic Grammar Exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.