Advertisement
imedvedev

Untitled

Mar 14th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?
  2. function trueTable($x1, $x2, $x3, $x4) {
  3.     return implication(disjunction($x4, invers($x3, $x2)), xor2($x2, disjunction($x3, implication($x1, $x2)))) ? 1 : 0;
  4. }
  5.  
  6. function disjunction($x1, $x2) {
  7.     return $x1 || $x2;
  8. }
  9.  
  10. function conjunction($x1, $x2) {
  11.     return $x1 && $x2;
  12. }
  13.  
  14. function xor2($x1, $x2) {
  15.     return $a xor $b;
  16. }
  17.  
  18. function invers($x1, $x2) {
  19.     return !$x2;
  20. }
  21.  
  22. function implication($x1, $x2) {
  23.     return $x1 && !$x2 ? false : true;
  24. }
  25. ?>
  26.  
  27. <!doctype html>
  28. <html lang="en">
  29. <head>
  30.     <meta charset="UTF-8">
  31.     <title>№3</title>
  32.     <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootswatch/3.1.1/flatly/bootstrap.min.css">
  33. </head>
  34. <body>
  35. <br>
  36. <center>
  37.     <b>Тру Не Тру</b><br>
  38.     <small>(X4+X3↔X2)↔(X2⊕(X3+X1→X2))</small><br><br>
  39. </center>
  40. <div class="container">
  41.     <table class="table table-striped" style="width:100px; margin: 0 auto;">
  42.         <thead>
  43.             <th>X1</th>
  44.             <th>X2</th>
  45.             <th>X3</th>
  46.             <th>X4</th>
  47.             <th>F</th>
  48.         </thead>
  49.         <tbody>
  50.         <?
  51.         for($x1 = 0; $x1 <= 1; $x1++) {
  52.             for($x2 = 0; $x2 <= 1; $x2++) {
  53.                 for($x3 = 0; $x3 <= 1; $x3++) {
  54.                     for($x4 = 0; $x4 <= 1; $x4++) {
  55.                         ?>
  56.                         <tr>
  57.                             <td><?=$x1?></td>
  58.                             <td><?=$x2?></td>
  59.                             <td><?=$x3?></td>
  60.                             <td><?=$x4?></td>
  61.                             <td><?=trueTable($x1, $x2, $x3, $x4)?></td>
  62.                         </tr>              
  63.                         <?
  64.                     }
  65.                 }
  66.             }  
  67.         }
  68.         ?>
  69.         </tbody>
  70.     </table>
  71.  
  72. </div>
  73.  
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement