| 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!
|