Guest User

Untitled

a guest
Dec 6th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. $handle = fopen ("php://stdin","r");
  2. fscanf($handle,"%d",$n);
  3. $arr_temp = fgets($handle);
  4. $arr = explode(" ",$arr_temp);
  5. array_walk($arr,'intval');
  6.  
  7. $pos = 0; $neg = 0; $null = 0;
  8. foreach($arr AS $key=>$value) {
  9. if ($value==0) {
  10. $null++;
  11. } elseif ($value>0) {
  12. $pos++;
  13. } else {
  14. $neg++;
  15. }
  16. }
  17. echo round($pos/$n,6)."\n";
  18. echo round($neg/$n,6)."\n";
  19. echo round($null/$n,6);
Advertisement
Add Comment
Please, Sign In to add comment