Requirement: A set of data that is graded by a group of judges.
 
 
  
  - Find their maximum and minimum values.
- The corner label of the maximum minimum value
- To remove the average after the maximum and minimum values
Code:
1<?PHP2     $arr=Array(1,2,3,4);3     //Minimum Value4 //idea: 44,5,3,333,445,99,54,332,-65 //1. Define variables, one record subscript $index, one record minimum value $minvalue6 //2. If the minimum value is a number with a subscript of 07 //3. Compare the value that is considered to be the minimum to the number in the array8 //4. If $minvalue is larger than a certain number in the array, the number is not the minimum value. Exchange subscript and minimum values9     functionMinfunction ($arr){Ten         $index=0; One         $minvalue=$arr[0]; A          for($i= 1;$i<Count($arr) ;$i++) {  -             if($minvalue>$arr[$i]) { -                 $index=$i; the                 $minvalue=$arr[$i]; -             } -         } -         return $index; +     } -     $a=minfunction ($arr); +     //echo $a; A     EchoThe minimum value is$a, his score was$arr[$a]"; at     Echo"<br/>"; -     //Maximum Value - //idea: Same as the minimum idea -     functionMaxfunction ($arr){ -     $index=0; -     $minvalue=$arr[0]; in      for($i= 1;$i<Count($arr) ;$i++) {  -         if($minvalue<$arr[$i]) { to             $index=$i; +             $minvalue=$arr[$i]; -         } the     } *     return $index; $ }Panax Notoginseng     $b=maxfunction ($arr); -     //echo $a; the     EchoThe maximum value is$b, his score was$arr[$b]"; +     Echo"<br/>"; A     //Average the //ideas: + //Define a variable record total score number - //2. Add a value other than the maximum value to the minimum value $ //3. Divide by Count ($arr)-2 to get the average. $     $sum=0; -      for($i= 0;$i<Count($arr) ;$i++) {  -         //echo $a. " = = = ". $b." ---". $i." <br/> "; the //$c = ($i! = $a) && ($i! = $b); - //Var_dump ($c);Wuyi //NOTE: The following conditions && the meaning of both are true before executing the following statement the         if(($i!=$a) && ($i!=$b)) {             -             $sum+=$arr[$i]; Wu             //echo $sum. " <br/> "; -         } About     } $     Echo"Remove the total of the maximum and minimum values into$sum"." <br/> "; -     Echo"Average is".$sum/(Count($arr)-2); -     Echo"<br/>"; -?>
Results:
The wrong points encountered in the course of doing a problem:
 
 
  
  - A comparison of the 52nd row of values is written ($arr [$i]!= $arr [$a] && ($arr [$i]!= $arr [$b]), and of course the result is true. Easier and quicker to compare subscripts
- The 52nd line operator, written as | |. After a long struggle how to 4 count he counted in. = = (silent for a burst). The original operator was wrong. Must be two to be true to overlay the value of sum
Summarize:
 
 
  
  - Find maximum and minimum values, use circular traversal sorting (sort by: bubble sort, select sort, courier Sort)
- Operator:&&, and (all true), or | | (any one is true). For details, refer to http://www.cnblogs.com/8013-cmf/p/7722966.html
"11" to find the maximum and maximum values of a set of arrays, the minimum value, the minimum value of the angle index and the average