31.10
This commit is contained in:
55
Zadania/Z86 - potencjometr/index.php
Normal file
55
Zadania/Z86 - potencjometr/index.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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>Z86 - Potencjometr</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Zadanie Z86</h1>
|
||||
<h2>Autor: Jakub Grzegorczyk</h2>
|
||||
</header>
|
||||
<div class="box">
|
||||
<p>Napisz program, który dla podanej liczby całkowitej a losuje a liczb w zakresie <1, 9>.i wyświetla je na ekranie w postaci: liczba i liczba znaków ‘|’.</p>
|
||||
<pre>
|
||||
Przykład a=5
|
||||
Wylosowane liczby: 5 3 6 3 1
|
||||
5|||||
|
||||
3|||
|
||||
6||||||
|
||||
3|||
|
||||
1|
|
||||
</pre>
|
||||
</div>
|
||||
<div class="box">
|
||||
<form action="index.php" method="post">
|
||||
<fieldset>
|
||||
<label for="a">Podaj A:</label>
|
||||
<input type="number" name="a" id="a" min="1" required>
|
||||
</fieldset>
|
||||
<button type="submit">Wyślij</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$a = htmlspecialchars($_POST['a']);
|
||||
echo '<div class="box">';
|
||||
$arr = array();
|
||||
for ($i = 0; $i < $a; $i++) {
|
||||
$arr[$i] = rand(1, 9);
|
||||
}
|
||||
$arrString = implode(', ', $arr);
|
||||
echo 'Wylosowane liczby: ' . $arrString . '<br>';
|
||||
for ($i = 0; $i < $a; $i++) {
|
||||
echo "$arr[$i] " . str_repeat('| ', $arr[$i]) . '<br>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user