This commit is contained in:
2p01
2025-05-28 11:21:16 +02:00
parent 2e0bb8c4ab
commit 4a12ac076e
9 changed files with 139 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
<?php
function jestOdkryta($liczba): bool
{
if ($liczba <= 0) {
return false;
}
$cyfry = str_split((string)$liczba);
foreach ($cyfry as $cyfra) {
if ($cyfra == '0') {
continue;
}
if ($liczba % (int)$cyfra != 0) {
return false;
}
}
return true;
}
echo "Zadanie P51a - Liczba odkryta<br>";
echo jestOdkryta(24) ? "True" : "False";

View File

@@ -0,0 +1,52 @@
<!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>P51b - Szachownica</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie P51b</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz kod php z funkcją szachownica($a). Funkcja przyjmuje jeden parametr. który określa ilość kratek w wierszu i kolumnie.</p>
</div>
<div class="box">
<form action="index.php" method="post">
<label for="a">Wprowadź liczbę A:</label><br>
<input type="number" name="a" id="a"><br>
<button type="submit">Wyślij</button>
</form>
</div>
<div class="box">
<?php
function szachownica($a): void
{
echo "<table>";
$y = true;
for ($i = 0; $i < $a; $i++) {
echo "<tr>";
for ($j = 0; $j < $a; $j++) {
if ($y == true) {
echo "<td class='y'></td>";
} else {
echo "<td class='b'></td>";
}
}
echo "</tr>";
}
echo "</table>";
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
szachownica($_POST["a"]);
}
?>
</div>
</body>
</html>

View File

@@ -0,0 +1,68 @@
* {
box-sizing: border-box;
}
body {
font-family: Verdana, serif;
background: #ffffff;
margin: 15px;
font-size: 0.9em;
}
header {
border: 2px solid black;
border-radius: 1em;
padding: 10px 20px;
box-shadow: rgba(0, 0, 0, 0.2) 3px 3px 5px;
background: #f0f0f0;
}
input {
margin-top: 5px;
margin-bottom: 5px;
width: 30%;
border: black 2px solid;
border-radius: 0.5em;
height: 2em;
}
button {
padding: 5px;
width: 30%;
border: black 2px solid;
border-radius: 0.5em;
font-weight: bold;
margin-top: 10px;
}
pre {
font-family: Verdana, serif;
}
.box {
border: 2px solid black;
padding: 15px 20px;
border-radius: 1em;
margin: 15px 0 10px 0;
box-shadow: rgba(0, 0, 0, 0.2) 3px 3px 5px;
}
.box h3 {
cursor: pointer;
}
td {
width: 50px;
height: 50px;
margin: 0;
padding: 0;
}
tr {
padding: 0;
}
.y {
background: yellow;
}
.b {
background:blue;
}