31.10
This commit is contained in:
47
Zadania/Z90 - podzielne przez K/index.php
Normal file
47
Zadania/Z90 - podzielne przez K/index.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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>Z90 - Podzielne przez K</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Zadanie Z90</h1>
|
||||
<h2>Autor: Jakub Grzegorczyk</h2>
|
||||
</header>
|
||||
<div class="box">
|
||||
<p>Napisz program, który dla podanej wartości zmiennej n i k wyświetla wszystkie liczby z przedziału <1, n> podzielne przez k.</p>
|
||||
</div>
|
||||
<div class="box">
|
||||
<form action="index.php" method="post">
|
||||
<fieldset>
|
||||
<label for="n">Podaj N:</label>
|
||||
<input type="number" name="n" id="n" required>
|
||||
<label for="k">Podaj K:</label>
|
||||
<input type="number" name="k" id="k" required>
|
||||
</fieldset>
|
||||
<button type="submit">Wyślij</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$n = htmlspecialchars($_POST['n']);
|
||||
$k = htmlspecialchars($_POST['k']);
|
||||
echo '<div class="box">';
|
||||
$arr = array();
|
||||
for ($i = 1; $i <= $n; $i++) {
|
||||
if ($i % $k == 0) {$arr[] = $i;}
|
||||
}
|
||||
echo 'N = <b>' . $n . '</b><br>';
|
||||
echo 'K = <b>' . $k . '</b><br>';
|
||||
echo 'Liczby podzielne przez ' . $k . ' to : <b>' . implode(', ', $arr) . '</b>';
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user