Advertisement
mcnc

matrica

Nov 20th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <!--
  4. To change this license header, choose License Headers in Project Properties.
  5. To change this template file, choose Tools | Templates
  6. and open the template in the editor.
  7. -->
  8. <html>
  9. <head>
  10. <meta charset="UTF-8">
  11. <title>Matrica</title>
  12. </head>
  13. <style>
  14. table, th, tr {
  15. border: 1px solid black;
  16. border-collapse: collapse;
  17. }
  18. th, td {
  19. padding: 5px;
  20. text-align: center;
  21. }
  22. </style>
  23. <body>
  24. <form action="index.php" method="post">
  25. <p>Klikom na dugme generise se matrica dimenzija n koja ispisuje vrednost 0 po dijagonali</p>
  26. <p>n: <input type="number" name="n" /></p>
  27. <p><input type="submit" name="submit" value="Upisi" /></p>
  28. <?php
  29. if (!empty($_POST["n"]))
  30. {
  31. $n = $_POST["n"];
  32. echo "<table border = '1'>";
  33.  
  34. echo "<tr>";
  35. for ($i = 1; $i <= $n; $i++){
  36. for ($x = 1; $x <= $n; $x++){
  37. echo "<td>";
  38. if ($i == $x)
  39. echo 0;
  40. else
  41. echo 1;
  42. }
  43. echo "<tr>";
  44. }
  45. echo "</table>";
  46. }
  47. ?>
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement