Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <!--
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
- -->
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Matrica</title>
- </head>
- <style>
- table, th, tr {
- border: 1px solid black;
- border-collapse: collapse;
- }
- th, td {
- padding: 5px;
- text-align: center;
- }
- </style>
- <body>
- <form action="index.php" method="post">
- <p>Klikom na dugme generise se matrica dimenzija n koja ispisuje vrednost 0 po dijagonali</p>
- <p>n: <input type="number" name="n" /></p>
- <p><input type="submit" name="submit" value="Upisi" /></p>
- <?php
- if (!empty($_POST["n"]))
- {
- $n = $_POST["n"];
- echo "<table border = '1'>";
- echo "<tr>";
- for ($i = 1; $i <= $n; $i++){
- for ($x = 1; $x <= $n; $x++){
- echo "<td>";
- if ($i == $x)
- echo 0;
- else
- echo 1;
- }
- echo "<tr>";
- }
- echo "</table>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement