YourPaste - For your paste! Archive - Tools - Login

Posted by FreakyFries on Thu 13 Nov 2008 20:03 94 views - Syntax: PHP - Expires: never - Report - IMG - Download -

  1. <?php
  2.  
  3. function tijdTotGelijk ($x, $y, $x_groei, $y_groei)
  4. {
  5.         if(($x > $y && $x_groei > $y_groei) || ($x > $y && $x_groei > $y_groei))
  6.         {
  7.                 echo 'Grootste getal groeit harder dan kleine getal.';
  8.                 return false;
  9.         }
  10.         elseif($x == $y)
  11.         {
  12.                 echo 'Getallen zijn gelijk.';
  13.                 return false;
  14.         }
  15.         else
  16.         {
  17.                 // Zorg ervoor dat $a de grootste is
  18.                 if($x > $y)
  19.                 {
  20.                         $a = $x;
  21.                         $a_groei = $x_groei;
  22.                         $b = $y;
  23.                         $b_groei = $y_groei;
  24.                 }
  25.                 else
  26.                 {
  27.                         $a = $y;
  28.                         $a_groei = $y_groei;
  29.                         $b = $x;
  30.                         $b_groei = $x_groei;
  31.                        
  32.                 }
  33.                
  34.                 $verschil = $a - $b;
  35.                 $verschil_groei = $b_groei - $a_groei;
  36.                
  37.                 $resultaat = $verschil / $verschil_groei;
  38.                
  39.                 return $resultaat;
  40.         }
  41. }
  42.  
  43. function tijdTotGelijk2($x, $y, $x_groei, $y_groei)
  44. {
  45.         return = abs(($x - $y) / ($x_groei - $y_groei));
  46. }
  47. echo tijdTotGelijk(50, 20, 3, 10); // Geeft als resultaat: 4.28571428571
  48. echo tijdTotGelijk2(50, 20, 3, 10); // Geeft als resultaat: 4.28571428571
  49.  
  50. ?>

Comments


Name:
Comment:

© 2008 YourPaste.net - Disclaimer