42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<!doctype html>
|
|
<html lang="pl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport"
|
|
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>Z81 - Odwrócona Piramida</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>Zadanie Z81</h1>
|
|
<h2>Autor: Jakub Grzegorczyk</h2>
|
|
</header>
|
|
<div class="box">
|
|
<p>Napisz program, który dla podanej liczby całkowitej A wyświetla piramidę znaków X o ilości wierszy równej A (maksymalna wartość A = 50).</p>
|
|
</div>
|
|
<div class="box">
|
|
<form action="index.php" method="post">
|
|
<fieldset>
|
|
<label for="a">Podaj liczbę A:</label>
|
|
<input type="number" name="a" id="a" max="50" min="1" required>
|
|
</fieldset>
|
|
<button type="submit">Wyślij</button>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
$a = (int)htmlspecialchars($_POST['a']);
|
|
echo '<div class="box" style="">';
|
|
echo "A: $a <br>";
|
|
for ($i = $a; $i >= 1; $i--) {
|
|
echo str_repeat('X', $i);
|
|
echo '<br>';
|
|
}
|
|
echo '</div>';
|
|
}
|
|
?>
|
|
</body>
|
|
</html>
|