Advertisement
apexsquirt

[PHP-CLI] Checking if a finite structure is a magma

Jul 15th, 2018
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2.  
  3. //Vérifie si <$array,rel> est un magma
  4.  
  5. function rel($x,$y) {   // relation
  6.     return $x**$y;
  7. }
  8. $array = [1];           // array
  9.  
  10. $cloture = "Oui";
  11. for ($i = 0; $i < count($array); $i++) {
  12.     for ($j = 0; $j < count($array); $j++) {
  13.         if (!in_array(rel($array[$i],$array[$j]),$array)) {
  14.             $cloture = "Non";
  15.         }
  16.     }
  17. }
  18. print "Clotûre : ".$cloture."\n";
  19. if ($cloture == "Oui") {
  20.     print "C'est un magma";
  21. } else {
  22.     print "C'est pas un magma";
  23. }
  24. echo `pause>nul`;
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement