PHP Basics Tutorial PHP Array Exercises

Source: Internet
Author: User
This section for you to introduce the PHP array of exercises, a diving game results of the exercises, for everyone to learn the reference.

Title: 1, diving competition, 8 judges scoring, the athlete's performance is 8 grades to remove a highest score and remove a minimum score. The average of the remaining 6 points is the final score. Use a one-dimensional array to achieve the scoring function. 2, and the highest score and the lowest score of the judges to find out.

Example 1:1.php

 
      

Ask the referee to enter the score

Example 2:2.php

     ";//define variables to calculate total $total=0;/*for ($i =0; $i
     
      
      
"; $total + = $arr [$i];} */foreach ($arr as $v) {$total + = $v;} echo $total. "
";//minus the highest minimum score, the last score//Average score//round function reserved decimal Place | | This is rounding method reserved 3 decimal $last= ($total-max ($arr)-min ($arr))/(count ($arr)-2);//$last = ($total-max ($arr)-min ($arr)); Echo ' The final score of the highest and lowest points is divided into: '. ($total-max ($arr)-min ($arr)). "
"; Echo ' the average of the final score minus the highest score and the lowest score is divided into: '. Round ($last, 3)."
";//Find out the Key:array_search function for maximum and minimum mappings. $max _k=array_search (Max ($arr), $arr), $min _k=array_search (min ($arr), $arr); Echo ' highest score is first '. ($max _k+1). ' The judges beat '. Max ($arr). ' Score of
' The Echo ' lowest score is '. ($min _k+1). ' The judges played '. Min ($arr). ' Score of
';? >

Thank you for your attention to the PHP introductory tutorial, this series of basic PHP tutorial will help PHP novice friends, quickly master the language of PHP programming. The programmer's home will continue to introduce PHP-related tutorials For everyone, I wish you all the progress of learning!

  • 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.