This commit is contained in:
jakub
2025-12-09 21:04:59 +01:00
parent f5d75c0941
commit 982a62c63c
15 changed files with 2689 additions and 6 deletions

View File

@@ -0,0 +1,94 @@
<?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>Z100 - suma nad przekątną</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z100</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz program, który wypełnia liczbami tablicę o wymiarach n x n i oblicza sumę elementów nad główną przekątną. Główną przekątną kwadratowej tablicy rozumiemy jako łączącą lewy górny róg tablicy z prawym dolnym (czyli elementy [0][0], [1][1], ..., [n-1][n-1]). Użytkownik podaje n oraz wprowadza liczby do komponentu textarea oddzielone przecinkami. Program powinien zweryfikować, czy n jest liczbą całkowitą, czy podane wartości są liczbami, czy ich liczba zgadza się z n x n, a następnie wyświetlić tablicę i sumę elementów nad główną przekątną.</p>
<h3>Wskazówki dla ucznia:</h3>
<ul>
<li>Sprawdź, czy n i m są liczbami całkowitymi (is_numeric() i is_int() po konwersji).</li>
<li>Użyj explode(), aby rozdzielić ciąg z textarea na tablicę liczb na podstawie przecinków.</li>
<li>Zweryfikuj, czy każda wartość jest liczbą całkowitą za pomocą is_numeric() i sprawdzenia, czy po konwersji na int nie traci wartości dziesiętnej.</li>
<li>Przekształć jednowymiarową tablicę na dwuwymiarową, rozdzielając ją na wiersze po m elementów.</li>
<li>Oblicz sumę elementów nad główną przekątną, czyli tych, gdzie indeks kolumny j jest większy niż indeks wiersza i (j > i).</li>
<li>Zabezpiecz dane wejściowe za pomocą htmlspecialchars() przy pobieraniu, aby chronić przed XSS.</li>
</ul>
</div>
<div class="box">
<form action="index.php" method="post">
<fieldset>
<legend>Wymiar tablicy</legend>
<label for="n">N:</label>
<input type="number" name="n" id="n" max="100" min="0" required>
</fieldset>
<fieldset>
<legend>Wartości tablicy (liczby oddzielone przecinkami):</legend>
<label for="values"></label>
<textarea name="values" id="values" cols="30" rows="10" placeholder="np. 1, 2, 3, 4"></textarea>
</fieldset>
<button type="submit">Wyślij</button>
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$nInput = htmlspecialchars($_POST['n']);
$valuesInput = htmlspecialchars($_POST['values']);
$isValidDimensions = is_numeric($nInput) &&
(int)$nInput == $nInput &&
(int)$nInput > 0;
$n = (int)$nInput;
$values = array_map('trim', explode(',', $valuesInput));
$count = count($values);
$isCountValid = $count === $n*$n;
$areAllValuesValid = true;
foreach ($values as $value) {
if (!is_numeric($value)) { $areAllValuesValid = false; }
else { $value = (int)$value;}
}
echo '<div class="box">';
if ($areAllValuesValid && $isValidDimensions && $isCountValid) {
$values2d = array_chunk($values, $n);
$diagonalSum = 0;
for ($i = 0; $i < $n; $i++) {
$diagonalSum += $values2d[$i][$i];
}
echo "Wymiar tablicy: n = $n<br>";
echo "Wprowadzone liczby: ";
echo implode(', ', $values);
echo "<br>Tablica $n x $n:";
echo '<table>';
for ($i = 0; $i < $n; $i++) {
echo '<tr>';
for ($j = 0; $j < $n; $j++) {
echo '<td>' . $values2d[$i][$j] . '</td>';
}
echo '</tr>';
}
echo '</table>';
echo "Suma elementów nad główną przekątną: $diagonalSum";
echo '</div>';
} else {
echo 'Dane wejściowe nie są poprawne! Sprawdź wymiary, liczbę wartości lub czy wszystkie są liczbami.';
}
echo '</div>';
}
?>
</body>
</html>

View File

@@ -0,0 +1,300 @@
/* === UNIVERSAL SCHOOL TEMPLATE CSS (BLACK & WHITE EDITION) === */
/* clean, modern, and copy-paste friendly for all projects */
/* === RESET === */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* === VARIABLES === */
:root {
--accent: #000;
--border: #000;
--bg: #fff;
--bg-alt: #f7f7f7;
--text: #111;
--shadow: rgba(0, 0, 0, 0.15) 3px 3px 6px;
--radius: 1em;
--max-width: 1300px;
}
/* === PAGE === */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Verdana, sans-serif;
background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
color: var(--text);
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
line-height: 1.6;
}
/* === HEADER === */
header {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 20px 30px;
box-shadow: var(--shadow);
background: var(--bg);
width: 95%;
max-width: var(--max-width);
text-align: center;
margin-top: 25px;
transition: box-shadow 0.3s ease, transform 0.2s ease;
}
header:hover {
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
transform: translateY(-2px);
}
header h1 {
font-size: 2.2rem;
}
header h2 {
margin-top: 0.5rem;
font-weight: 400;
font-size: 1.1rem;
color: #444;
}
/* === BOX === */
.box {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 25px 35px;
margin-top: 25px;
background: var(--bg);
box-shadow: var(--shadow);
width: 95%;
max-width: var(--max-width);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box:hover {
transform: translateY(-2px);
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
}
/* === TEXT ELEMENTS === */
p {
margin-bottom: 1rem;
}
.box > p:last-child {
margin-bottom: 0;
}
h1, h2, h3, h4 {
margin-bottom: 0.5rem;
font-weight: 600;
}
a {
color: #000;
text-decoration: underline;
font-weight: 500;
}
a:hover {
opacity: 0.7;
}
/* === LISTS === */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
}
li {
margin-bottom: 0.4rem;
}
/* === TABLES === */
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background: var(--bg);
border: 2px solid var(--border);
border-radius: 0.6em;
overflow: hidden;
box-shadow: var(--shadow);
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid #ccc;
text-align: center;
}
th {
background: var(--bg-alt);
font-weight: bold;
text-align: left;
}
tr:hover {
background: #f2f2f2;
}
/* === FORMS === */
form {
display: flex;
flex-direction: column;
gap: 1.4rem;
}
.box:has(> form) {
padding: 35px 35px;
}
fieldset {
border: 2px solid var(--border);
border-radius: 0.8em;
padding: 1.2rem 1.5rem;
background: var(--bg-alt);
}
legend {
font-weight: bold;
color: #000;
padding: 0 0.4rem;
font-size: 1.05rem;
}
label {
font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
textarea,
select {
width: 100%;
font-size: 1rem;
margin-top: 6px;
margin-bottom: 8px;
border: 2px solid var(--border);
border-radius: 0.5em;
padding: 0.4rem 0.5rem;
transition: all 0.2s ease;
background: var(--bg);
}
textarea {
resize: vertical;
min-height: 100px;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border-color: #000;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
background: #f9f9f9;
}
input[type="radio"],
input[type="checkbox"] {
accent-color: #000;
transform: scale(1.2);
margin-right: 0.3rem;
}
/* === BUTTONS === */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
padding: 10px 20px;
border: 2px solid var(--border);
border-radius: 0.5em;
font-weight: bold;
font-size: 1rem;
background: linear-gradient(180deg, #fff 0%, #f2f2f2 100%);
cursor: pointer;
transition: all 0.2s ease;
align-self: flex-start;
}
button {
width: 100%;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
background: #eaeaea;
box-shadow: rgba(0, 0, 0, 0.25) 3px 3px 6px;
transform: translateY(-2px);
}
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
transform: translateY(0);
box-shadow: rgba(0, 0, 0, 0.15) 1px 1px 3px;
background: #f7f7f7;
}
/* === HR, CODE, ETC. === */
hr {
border: 0;
border-top: 2px solid var(--border);
margin: 1.5rem 0;
}
img {
max-width: 100%;
border-radius: 0.5em;
}
code, pre {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 0.4em;
padding: 0.3em 0.5em;
font-family: "Courier New", monospace;
}
pre {
padding: 1em;
overflow-x: auto;
}
/* === RESPONSIVE === */
@media (max-width: 900px) {
header, .box {
width: 95%;
padding: 20px;
}
button {
width: 100%;
}
textarea {
width: 100%;
}
}
@media (max-width: 600px) {
header h1 {
font-size: 1.7rem;
}
header h2 {
font-size: 0.95rem;
}
}

View File

@@ -0,0 +1,94 @@
<?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>Z101 - tablica potęgowa</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z101</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz program, który wypełnia liczbami tablicę o wymiarach n x 3. W pierwszej kolumnie znajduje się liczba podana przez użytkownika, w drugiej jej druga potęga, a w trzeciej trzecia potęga. Użytkownik podaje n oraz wprowadza n liczb do pierwszej kolumny w komponencie textarea oddzielonych przecinkami. Program powinien zweryfikować, czy n jest liczbą całkowitą, czy podane wartości są liczbami, czy ich liczba zgadza się z n, a następnie wyświetlić tablicę z wyliczonymi potęgami.</p>
<h3>Wskazówki dla ucznia:</h3>
<ul>
<li>Sprawdź, czy n i m są liczbami całkowitymi (is_numeric() i is_int() po konwersji).</li>
<li>Użyj explode(), aby rozdzielić ciąg z textarea na tablicę liczb na podstawie przecinków.</li>
<li>Zweryfikuj, czy każda wartość jest liczbą całkowitą za pomocą is_numeric() i sprawdzenia, czy po konwersji na int nie traci wartości dziesiętnej.</li>
<li>Przekształć jednowymiarową tablicę na dwuwymiarową, rozdzielając ją na wiersze po m elementów.</li>
<li>Oblicz drugą potęgę ($x * $x lub pow($x, 2)) i trzecią potęgę ($x * $x * $x lub pow($x, 3)) dla każdej liczby.</li>
<li>Zabezpiecz dane wejściowe za pomocą htmlspecialchars() przy pobieraniu, aby chronić przed XSS.</li>
</ul>
</div>
<div class="box">
<form action="index.php" method="post">
<fieldset>
<legend>Wymiar tablicy</legend>
<label for="n">N:</label>
<input type="number" name="n" id="n" max="100" min="0" required>
</fieldset>
<fieldset>
<legend>Wartości tablicy (liczby oddzielone przecinkami):</legend>
<label for="values"></label>
<textarea name="values" id="values" cols="30" rows="10" placeholder="np. 1, 2, 3, 4"></textarea>
</fieldset>
<button type="submit">Wyślij</button>
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$nInput = htmlspecialchars($_POST['n']);
$valuesInput = htmlspecialchars($_POST['values']);
$isValidDimensions = is_numeric($nInput) &&
(int)$nInput == $nInput &&
(int)$nInput > 0;
$n = (int)$nInput;
$values = array_map('trim', explode(',', $valuesInput));
$count = count($values);
$isCountValid = $count === $n;
$areAllValuesValid = true;
foreach ($values as $value) {
if (!is_numeric($value)) { $areAllValuesValid = false; }
else { $value = (int)$value;}
}
echo '<div class="box">';
if ($areAllValuesValid && $isValidDimensions && $isCountValid) {
$values2d[$n] = array();
for ($i = 0; $i < $n; $i++) {
$values2d[$i][0] = $values[$i];
$values2d[$i][1] = pow($values[$i], 2);
$values2d[$i][2] = pow($values[$i], 3);
}
echo "Wymiar tablicy: n = $n<br>";
echo "Wprowadzone liczby: ";
echo implode(', ', $values);
echo "<br>Tablica $n x 3:";
echo '<table>';
for ($i = 0; $i < $n; $i++) {
echo '<tr>';
for ($j = 0; $j < 3; $j++) {
echo '<td>' . $values2d[$i][$j] . '</td>';
}
echo '</tr>';
}
echo '</table>';
echo '</div>';
} else {
echo 'Dane wejściowe nie są poprawne! Sprawdź wymiary, liczbę wartości lub czy wszystkie są liczbami.';
}
echo '</div>';
}
?>
</body>
</html>

View File

@@ -0,0 +1,300 @@
/* === UNIVERSAL SCHOOL TEMPLATE CSS (BLACK & WHITE EDITION) === */
/* clean, modern, and copy-paste friendly for all projects */
/* === RESET === */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* === VARIABLES === */
:root {
--accent: #000;
--border: #000;
--bg: #fff;
--bg-alt: #f7f7f7;
--text: #111;
--shadow: rgba(0, 0, 0, 0.15) 3px 3px 6px;
--radius: 1em;
--max-width: 1300px;
}
/* === PAGE === */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Verdana, sans-serif;
background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
color: var(--text);
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
line-height: 1.6;
}
/* === HEADER === */
header {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 20px 30px;
box-shadow: var(--shadow);
background: var(--bg);
width: 95%;
max-width: var(--max-width);
text-align: center;
margin-top: 25px;
transition: box-shadow 0.3s ease, transform 0.2s ease;
}
header:hover {
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
transform: translateY(-2px);
}
header h1 {
font-size: 2.2rem;
}
header h2 {
margin-top: 0.5rem;
font-weight: 400;
font-size: 1.1rem;
color: #444;
}
/* === BOX === */
.box {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 25px 35px;
margin-top: 25px;
background: var(--bg);
box-shadow: var(--shadow);
width: 95%;
max-width: var(--max-width);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box:hover {
transform: translateY(-2px);
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
}
/* === TEXT ELEMENTS === */
p {
margin-bottom: 1rem;
}
.box > p:last-child {
margin-bottom: 0;
}
h1, h2, h3, h4 {
margin-bottom: 0.5rem;
font-weight: 600;
}
a {
color: #000;
text-decoration: underline;
font-weight: 500;
}
a:hover {
opacity: 0.7;
}
/* === LISTS === */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
}
li {
margin-bottom: 0.4rem;
}
/* === TABLES === */
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background: var(--bg);
border: 2px solid var(--border);
border-radius: 0.6em;
overflow: hidden;
box-shadow: var(--shadow);
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid #ccc;
text-align: center;
}
th {
background: var(--bg-alt);
font-weight: bold;
text-align: left;
}
tr:hover {
background: #f2f2f2;
}
/* === FORMS === */
form {
display: flex;
flex-direction: column;
gap: 1.4rem;
}
.box:has(> form) {
padding: 35px 35px;
}
fieldset {
border: 2px solid var(--border);
border-radius: 0.8em;
padding: 1.2rem 1.5rem;
background: var(--bg-alt);
}
legend {
font-weight: bold;
color: #000;
padding: 0 0.4rem;
font-size: 1.05rem;
}
label {
font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
textarea,
select {
width: 100%;
font-size: 1rem;
margin-top: 6px;
margin-bottom: 8px;
border: 2px solid var(--border);
border-radius: 0.5em;
padding: 0.4rem 0.5rem;
transition: all 0.2s ease;
background: var(--bg);
}
textarea {
resize: vertical;
min-height: 100px;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border-color: #000;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
background: #f9f9f9;
}
input[type="radio"],
input[type="checkbox"] {
accent-color: #000;
transform: scale(1.2);
margin-right: 0.3rem;
}
/* === BUTTONS === */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
padding: 10px 20px;
border: 2px solid var(--border);
border-radius: 0.5em;
font-weight: bold;
font-size: 1rem;
background: linear-gradient(180deg, #fff 0%, #f2f2f2 100%);
cursor: pointer;
transition: all 0.2s ease;
align-self: flex-start;
}
button {
width: 100%;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
background: #eaeaea;
box-shadow: rgba(0, 0, 0, 0.25) 3px 3px 6px;
transform: translateY(-2px);
}
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
transform: translateY(0);
box-shadow: rgba(0, 0, 0, 0.15) 1px 1px 3px;
background: #f7f7f7;
}
/* === HR, CODE, ETC. === */
hr {
border: 0;
border-top: 2px solid var(--border);
margin: 1.5rem 0;
}
img {
max-width: 100%;
border-radius: 0.5em;
}
code, pre {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 0.4em;
padding: 0.3em 0.5em;
font-family: "Courier New", monospace;
}
pre {
padding: 1em;
overflow-x: auto;
}
/* === RESPONSIVE === */
@media (max-width: 900px) {
header, .box {
width: 95%;
padding: 20px;
}
button {
width: 100%;
}
textarea {
width: 100%;
}
}
@media (max-width: 600px) {
header h1 {
font-size: 1.7rem;
}
header h2 {
font-size: 0.95rem;
}
}

View File

@@ -0,0 +1,66 @@
<?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>Z102 - lewy górny</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z102</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz program, który do dwuwymiarowej tablicy o wymiarach 3 x 3 wpisuje liczby pseudolosowe z zakresu <0,9>, wyświetla tą tablicę, a następnie oblicza sumę liczb rozmieszczonych wzdłuż przekątnych:</p>
<ul>
<li>Przekątna LG_PD - lewy górny i prawy dolny,</li>
<li>Przekątna LD_PG - lewy dolny i prawy górny.</li>
</ul>
<p>Program wyświetla te sumy i odpowiada na pytanie, która z nich jest większa, lub czy są równe.</p>
</div>
<div class="box">
<form method="post" action="index.php">
<button type="submit">Rozwiąż</button>
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$values[] = array();
for ($i = 0; $i < 3; $i++) {
for ($j = 0; $j < 3; $j++) {
$values[$i][$j] = (int)rand(1, 9);
}
}
$sumLG_PD = $values[0][0] + $values[2][2];
$sumLD_PG = $values[0][2] + $values[2][0];
echo '<div class="box">';
echo "Tablica 3 x 3:";
echo '<table>';
for ($i = 0; $i < 3; $i++) {
echo '<tr>';
for ($j = 0; $j < 3; $j++) {
echo '<td>' . $values[$i][$j] . '</td>';
}
echo '</tr>';
}
echo '</table>';
echo "<b>LG_PD</b>: " . $sumLG_PD . '<br>';
echo "<b>LD_PG</b>: " . $sumLD_PG . '<br>';
echo '<hr>';
if ($sumLD_PG > $sumLG_PD) {
echo "LG_PD < LD_PG";
} else if ($sumLD_PG == $sumLG_PD) {
echo "LG_PD = LD_PG";
} else {
echo "LG_PD > LD_PG";
}
echo '</div>';
}
?>
</body>
</html>

View File

@@ -0,0 +1,300 @@
/* === UNIVERSAL SCHOOL TEMPLATE CSS (BLACK & WHITE EDITION) === */
/* clean, modern, and copy-paste friendly for all projects */
/* === RESET === */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* === VARIABLES === */
:root {
--accent: #000;
--border: #000;
--bg: #fff;
--bg-alt: #f7f7f7;
--text: #111;
--shadow: rgba(0, 0, 0, 0.15) 3px 3px 6px;
--radius: 1em;
--max-width: 1300px;
}
/* === PAGE === */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Verdana, sans-serif;
background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
color: var(--text);
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
line-height: 1.6;
}
/* === HEADER === */
header {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 20px 30px;
box-shadow: var(--shadow);
background: var(--bg);
width: 95%;
max-width: var(--max-width);
text-align: center;
margin-top: 25px;
transition: box-shadow 0.3s ease, transform 0.2s ease;
}
header:hover {
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
transform: translateY(-2px);
}
header h1 {
font-size: 2.2rem;
}
header h2 {
margin-top: 0.5rem;
font-weight: 400;
font-size: 1.1rem;
color: #444;
}
/* === BOX === */
.box {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 25px 35px;
margin-top: 25px;
background: var(--bg);
box-shadow: var(--shadow);
width: 95%;
max-width: var(--max-width);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box:hover {
transform: translateY(-2px);
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
}
/* === TEXT ELEMENTS === */
p {
margin-bottom: 1rem;
}
.box > p:last-child {
margin-bottom: 0;
}
h1, h2, h3, h4 {
margin-bottom: 0.5rem;
font-weight: 600;
}
a {
color: #000;
text-decoration: underline;
font-weight: 500;
}
a:hover {
opacity: 0.7;
}
/* === LISTS === */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
}
li {
margin-bottom: 0.4rem;
}
/* === TABLES === */
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background: var(--bg);
border: 2px solid var(--border);
border-radius: 0.6em;
overflow: hidden;
box-shadow: var(--shadow);
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid #ccc;
text-align: center;
}
th {
background: var(--bg-alt);
font-weight: bold;
text-align: left;
}
tr:hover {
background: #f2f2f2;
}
/* === FORMS === */
form {
display: flex;
flex-direction: column;
gap: 1.4rem;
}
.box:has(> form) {
padding: 35px 35px;
}
fieldset {
border: 2px solid var(--border);
border-radius: 0.8em;
padding: 1.2rem 1.5rem;
background: var(--bg-alt);
}
legend {
font-weight: bold;
color: #000;
padding: 0 0.4rem;
font-size: 1.05rem;
}
label {
font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
textarea,
select {
width: 100%;
font-size: 1rem;
margin-top: 6px;
margin-bottom: 8px;
border: 2px solid var(--border);
border-radius: 0.5em;
padding: 0.4rem 0.5rem;
transition: all 0.2s ease;
background: var(--bg);
}
textarea {
resize: vertical;
min-height: 100px;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border-color: #000;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
background: #f9f9f9;
}
input[type="radio"],
input[type="checkbox"] {
accent-color: #000;
transform: scale(1.2);
margin-right: 0.3rem;
}
/* === BUTTONS === */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
padding: 10px 20px;
border: 2px solid var(--border);
border-radius: 0.5em;
font-weight: bold;
font-size: 1rem;
background: linear-gradient(180deg, #fff 0%, #f2f2f2 100%);
cursor: pointer;
transition: all 0.2s ease;
align-self: flex-start;
}
button {
width: 100%;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
background: #eaeaea;
box-shadow: rgba(0, 0, 0, 0.25) 3px 3px 6px;
transform: translateY(-2px);
}
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
transform: translateY(0);
box-shadow: rgba(0, 0, 0, 0.15) 1px 1px 3px;
background: #f7f7f7;
}
/* === HR, CODE, ETC. === */
hr {
border: 0;
border-top: 2px solid var(--border);
margin: 1.5rem 0;
}
img {
max-width: 100%;
border-radius: 0.5em;
}
code, pre {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 0.4em;
padding: 0.3em 0.5em;
font-family: "Courier New", monospace;
}
pre {
padding: 1em;
overflow-x: auto;
}
/* === RESPONSIVE === */
@media (max-width: 900px) {
header, .box {
width: 95%;
padding: 20px;
}
button {
width: 100%;
}
textarea {
width: 100%;
}
}
@media (max-width: 600px) {
header h1 {
font-size: 1.7rem;
}
header h2 {
font-size: 0.95rem;
}
}

View File

@@ -0,0 +1,73 @@
<?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>Z103 - tablica znaków</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z103</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz program, który do dwuwymiarowej tablicy o wymiarach 7 x 7 wpisze wygenerowane losowo znaki w zakresie <'a','e'>, wyświetli tę tablicę, a następnie:</p>
<ul>
<li>wypisze ile razy w tablicy wystąpiła litera 'a',</li>
<li>wyświetli te numery wierszy, w których najczęściej wystąpiła litera 'b'.</li>
</ul>
<p>Program wyświetla te sumy i odpowiada na pytanie, która z nich jest większa, lub czy są równe.</p>
</div>
<div class="box">
<form method="post" action="index.php">
<button type="submit">Rozwiąż</button>
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$values[] = array();
for ($i = 0; $i < 7; $i++) {
for ($j = 0; $j < 7; $j++) {
$values[$i][$j] = chr(random_int(97, 101));
}
}
$countA = 0;
$rowCounts = [];
foreach ($values as $i => $row) {
$rowCounts[$i] = 0;
foreach ($row as $value) {
if ($value == 'b') {
$rowCounts[$i]++;
}
if ($value == 'a') {
$countA++;
}
}
}
$maxCount = max($rowCounts);
$rowsWithMax = array_keys($rowCounts, $maxCount);
echo '<div class="box">';
echo "Tablica 7 x 7:";
echo '<table>';
for ($i = 0; $i < 7; $i++) {
echo '<tr>';
for ($j = 0; $j < 7; $j++) {
echo '<td>' . $values[$i][$j] . '</td>';
}
echo '</tr>';
}
echo '</table>';
echo "Litera 'a' wystąpiła <b>$countA</b> razy.<br>";
echo "Najwięcej liter 'b' wystąpiło w wierszu/wierszach: ";
foreach($rowsWithMax as $rowIndex) {echo $rowIndex + 1; if($rowIndex != end($rowsWithMax)) {echo ', ';}}
echo " ($maxCount razy)" . '<br>';
echo '</div>';
}
?>
</body>
</html>

View File

@@ -0,0 +1,300 @@
/* === UNIVERSAL SCHOOL TEMPLATE CSS (BLACK & WHITE EDITION) === */
/* clean, modern, and copy-paste friendly for all projects */
/* === RESET === */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* === VARIABLES === */
:root {
--accent: #000;
--border: #000;
--bg: #fff;
--bg-alt: #f7f7f7;
--text: #111;
--shadow: rgba(0, 0, 0, 0.15) 3px 3px 6px;
--radius: 1em;
--max-width: 1300px;
}
/* === PAGE === */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Verdana, sans-serif;
background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
color: var(--text);
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
line-height: 1.6;
}
/* === HEADER === */
header {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 20px 30px;
box-shadow: var(--shadow);
background: var(--bg);
width: 95%;
max-width: var(--max-width);
text-align: center;
margin-top: 25px;
transition: box-shadow 0.3s ease, transform 0.2s ease;
}
header:hover {
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
transform: translateY(-2px);
}
header h1 {
font-size: 2.2rem;
}
header h2 {
margin-top: 0.5rem;
font-weight: 400;
font-size: 1.1rem;
color: #444;
}
/* === BOX === */
.box {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 25px 35px;
margin-top: 25px;
background: var(--bg);
box-shadow: var(--shadow);
width: 95%;
max-width: var(--max-width);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box:hover {
transform: translateY(-2px);
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
}
/* === TEXT ELEMENTS === */
p {
margin-bottom: 1rem;
}
.box > p:last-child {
margin-bottom: 0;
}
h1, h2, h3, h4 {
margin-bottom: 0.5rem;
font-weight: 600;
}
a {
color: #000;
text-decoration: underline;
font-weight: 500;
}
a:hover {
opacity: 0.7;
}
/* === LISTS === */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
}
li {
margin-bottom: 0.4rem;
}
/* === TABLES === */
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background: var(--bg);
border: 2px solid var(--border);
border-radius: 0.6em;
overflow: hidden;
box-shadow: var(--shadow);
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid #ccc;
text-align: center;
}
th {
background: var(--bg-alt);
font-weight: bold;
text-align: left;
}
tr:hover {
background: #f2f2f2;
}
/* === FORMS === */
form {
display: flex;
flex-direction: column;
gap: 1.4rem;
}
.box:has(> form) {
padding: 35px 35px;
}
fieldset {
border: 2px solid var(--border);
border-radius: 0.8em;
padding: 1.2rem 1.5rem;
background: var(--bg-alt);
}
legend {
font-weight: bold;
color: #000;
padding: 0 0.4rem;
font-size: 1.05rem;
}
label {
font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
textarea,
select {
width: 100%;
font-size: 1rem;
margin-top: 6px;
margin-bottom: 8px;
border: 2px solid var(--border);
border-radius: 0.5em;
padding: 0.4rem 0.5rem;
transition: all 0.2s ease;
background: var(--bg);
}
textarea {
resize: vertical;
min-height: 100px;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border-color: #000;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
background: #f9f9f9;
}
input[type="radio"],
input[type="checkbox"] {
accent-color: #000;
transform: scale(1.2);
margin-right: 0.3rem;
}
/* === BUTTONS === */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
padding: 10px 20px;
border: 2px solid var(--border);
border-radius: 0.5em;
font-weight: bold;
font-size: 1rem;
background: linear-gradient(180deg, #fff 0%, #f2f2f2 100%);
cursor: pointer;
transition: all 0.2s ease;
align-self: flex-start;
}
button {
width: 100%;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
background: #eaeaea;
box-shadow: rgba(0, 0, 0, 0.25) 3px 3px 6px;
transform: translateY(-2px);
}
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
transform: translateY(0);
box-shadow: rgba(0, 0, 0, 0.15) 1px 1px 3px;
background: #f7f7f7;
}
/* === HR, CODE, ETC. === */
hr {
border: 0;
border-top: 2px solid var(--border);
margin: 1.5rem 0;
}
img {
max-width: 100%;
border-radius: 0.5em;
}
code, pre {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 0.4em;
padding: 0.3em 0.5em;
font-family: "Courier New", monospace;
}
pre {
padding: 1em;
overflow-x: auto;
}
/* === RESPONSIVE === */
@media (max-width: 900px) {
header, .box {
width: 95%;
padding: 20px;
}
button {
width: 100%;
}
textarea {
width: 100%;
}
}
@media (max-width: 600px) {
header h1 {
font-size: 1.7rem;
}
header h2 {
font-size: 0.95rem;
}
}

View File

@@ -0,0 +1,45 @@
<?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>Z34 - Proste równoległe</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z34</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz program, który dla podanych dwóch równań prostych odpowie czy proste te są równoległe.</p>
</div>
<div class="box">
<form action="index.php" method="post">
<fieldset>
<legend><b>Dane dla pierwszej prostej y<sub>1</sub> = a<sub>1</sub>x + b<sub>1</sub></b></legend>
<label for="a">Input 1</label>
<input type="text" name="a" id="a">
<label for="b">Input 2</label>
<input type="text" name="b" id="b">
</fieldset>
<fieldset>
<legend><b>Dane dla drugiej prostej y<sub>2</sub> = a<sub>2</sub>x + b<sub>2</sub></b></legend>
<label for="a">Input 1</label>
<input type="text" name="a" id="a">
<label for="b">Input 2</label>
<input type="text" name="b" id="b">
</fieldset>
<button type="submit">Wyślij</button>
</form>
</div>
<?php
?>
</body>
</html>

View File

@@ -0,0 +1,300 @@
/* === UNIVERSAL SCHOOL TEMPLATE CSS (BLACK & WHITE EDITION) === */
/* clean, modern, and copy-paste friendly for all projects */
/* === RESET === */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* === VARIABLES === */
:root {
--accent: #000;
--border: #000;
--bg: #fff;
--bg-alt: #f7f7f7;
--text: #111;
--shadow: rgba(0, 0, 0, 0.15) 3px 3px 6px;
--radius: 1em;
--max-width: 1300px;
}
/* === PAGE === */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Verdana, sans-serif;
background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
color: var(--text);
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
line-height: 1.6;
}
/* === HEADER === */
header {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 20px 30px;
box-shadow: var(--shadow);
background: var(--bg);
width: 95%;
max-width: var(--max-width);
text-align: center;
margin-top: 25px;
transition: box-shadow 0.3s ease, transform 0.2s ease;
}
header:hover {
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
transform: translateY(-2px);
}
header h1 {
font-size: 2.2rem;
}
header h2 {
margin-top: 0.5rem;
font-weight: 400;
font-size: 1.1rem;
color: #444;
}
/* === BOX === */
.box {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 25px 35px;
margin-top: 25px;
background: var(--bg);
box-shadow: var(--shadow);
width: 95%;
max-width: var(--max-width);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box:hover {
transform: translateY(-2px);
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
}
/* === TEXT ELEMENTS === */
p {
margin-bottom: 1rem;
}
.box > p:last-child {
margin-bottom: 0;
}
h1, h2, h3, h4 {
margin-bottom: 0.5rem;
font-weight: 600;
}
a {
color: #000;
text-decoration: underline;
font-weight: 500;
}
a:hover {
opacity: 0.7;
}
/* === LISTS === */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
}
li {
margin-bottom: 0.4rem;
}
/* === TABLES === */
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background: var(--bg);
border: 2px solid var(--border);
border-radius: 0.6em;
overflow: hidden;
box-shadow: var(--shadow);
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid #ccc;
}
th {
background: var(--bg-alt);
font-weight: bold;
text-align: left;
}
tr:hover {
background: #f2f2f2;
}
/* === FORMS === */
form {
display: flex;
flex-direction: column;
gap: 1.4rem;
}
.box:has(> form) {
padding: 35px 35px;
}
fieldset {
border: 2px solid var(--border);
border-radius: 0.8em;
padding: 1.2rem 1.5rem;
background: var(--bg-alt);
}
legend {
font-weight: bold;
color: #000;
padding: 0 0.4rem;
font-size: 1.05rem;
}
label {
font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
textarea,
select {
width: 100%;
font-size: 1rem;
margin-top: 6px;
margin-bottom: 8px;
border: 2px solid var(--border);
border-radius: 0.5em;
padding: 0.4rem 0.5rem;
transition: all 0.2s ease;
background: var(--bg);
}
textarea {
resize: vertical;
min-height: 100px;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border-color: #000;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
background: #f9f9f9;
}
input[type="radio"],
input[type="checkbox"] {
accent-color: #000;
transform: scale(1.2);
margin-right: 0.3rem;
}
/* === BUTTONS === */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
padding: 10px 20px;
border: 2px solid var(--border);
border-radius: 0.5em;
font-weight: bold;
font-size: 1rem;
background: linear-gradient(180deg, #fff 0%, #f2f2f2 100%);
cursor: pointer;
transition: all 0.2s ease;
align-self: flex-start;
}
button {
width: 100%;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
background: #eaeaea;
box-shadow: rgba(0, 0, 0, 0.25) 3px 3px 6px;
transform: translateY(-2px);
}
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
transform: translateY(0);
box-shadow: rgba(0, 0, 0, 0.15) 1px 1px 3px;
background: #f7f7f7;
}
/* === HR, CODE, ETC. === */
hr {
border: 0;
border-top: 2px solid var(--border);
margin: 1.5rem 0;
}
img {
max-width: 100%;
border-radius: 0.5em;
}
code, pre {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 0.4em;
padding: 0.3em 0.5em;
font-family: "Courier New", monospace;
}
pre {
padding: 1em;
overflow-x: auto;
}
/* === RESPONSIVE === */
@media (max-width: 900px) {
header, .box {
width: 95%;
padding: 20px;
}
button {
width: 100%;
}
textarea {
width: 100%;
}
}
@media (max-width: 600px) {
header h1 {
font-size: 1.7rem;
}
header h2 {
font-size: 0.95rem;
}
}

View File

@@ -68,12 +68,9 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$isCountValid = $count === ($n*$m);
$areAllValuesValid = true;
for ($i = 0; $i < $count; $i++) {
if (!is_numeric($values[$i])) {
$areAllValuesValid = false;
} else {
$values[$i] = (int)$values[$i];
}
foreach ($values as $value) {
if (!is_numeric($value)) { $areAllValuesValid = false; }
else { $value = (int)$value;}
}
echo '<div class="box">';
if ($areAllValuesValid && $isValidDimensions && $isCountValid && $isRowNumValid) {

View File

@@ -0,0 +1,107 @@
<?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>Z98 - indeksy parzystych</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z98</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz program, który wczytuje liczby całkowite do tablicy o wymiarach n x m i wyświetla wskaźniki liczb parzystych w tablicy. Użytkownik podaje n i m oraz wprowadza liczby do komponentu textarea oddzielone przecinkami. Program powinien zweryfikować, czy n i m są liczbami całkowitymi, czy podane wartości są liczbami całkowitymi, czy ich liczba zgadza się z n x m, a następnie wyświetlić tablicę i indeksy (w formacie [wiersz][kolumna]) wszystkich liczb parzystych.</p>
<h3>Wskazówki dla ucznia:</h3>
<ul>
<li>Sprawdź, czy n i m są liczbami całkowitymi (is_numeric() i is_int() po konwersji).</li>
<li>Użyj explode(), aby rozdzielić ciąg z textarea na tablicę liczb na podstawie przecinków.</li>
<li>Zweryfikuj, czy każda wartość jest liczbą całkowitą za pomocą is_numeric() i sprawdzenia, czy po konwersji na int nie traci wartości dziesiętnej.</li>
<li>Przekształć jednowymiarową tablicę na dwuwymiarową, rozdzielając ją na wiersze po m elementów.</li>
<li>Przeszukaj tablicę dwuwymiarową pętlami i sprawdź parzystość za pomocą operatora % (modulo).</li>
<li>Zabezpiecz dane wejściowe za pomocą htmlspecialchars() przy pobieraniu, aby chronić przed XSS.</li>
</ul>
</div>
<div class="box">
<form action="index.php" method="post">
<fieldset>
<legend>Wymiary tablicy</legend>
<label for="n">Liczba wierszy (n):</label>
<input type="number" name="n" id="n" max="100" min="0" required>
<label for="m">Liczba kolumn (m):</label>
<input type="number" name="m" id="m" max="100" min="0" required>
</fieldset>
<fieldset>
<legend>Wartości tablicy (liczby całkowite oddzielone przecinkami):</legend>
<label for="values"></label>
<textarea name="values" id="values" cols="30" rows="10" placeholder="np. 1, 2, 3, 4"></textarea>
</fieldset>
<button type="submit">Wyślij</button>
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$nInput = htmlspecialchars($_POST['n']);
$mInput = htmlspecialchars($_POST['m']);
$valuesInput = htmlspecialchars($_POST['values']);
$isValidDimensions = is_numeric($nInput) && is_numeric($mInput) &&
(int)$nInput == $nInput &&
(int)$mInput == $mInput &&
(int)$nInput > 0 &&
(int)$mInput > 0;
$n = (int)$nInput;
$m = (int)$mInput;
$values = array_map('trim', explode(',', $valuesInput));
$count = count($values);
$isCountValid = $count === ($n*$m);
$areAllValuesValid = true;
foreach ($values as $value) {
if (!is_numeric($value)) { $areAllValuesValid = false; }
else { $value = (int)$value;}
}
echo '<div class="box">';
if ($areAllValuesValid && $isValidDimensions && $isCountValid) {
$values2d = array_chunk($values, $m);
$maxIndexes = array();
for ($i = 0; $i < $n; $i++) {
for ($j = 0; $j < $m; $j++) {
if ($values2d[$i][$j] % 2 == 0) {
$maxIndexes[] = array($i, $j);
}
}
}
echo "Wymiary tablicy: n = $n, m = $m<br>";
echo "Wprowadzone liczby: ";
echo implode(', ', $values);
echo "<br>Tablica $n x $m:";
echo '<table>';
for ($i = 0; $i < $n; $i++) {
echo '<tr>';
for ($j = 0; $j < $m; $j++) {
echo '<td>' . $values2d[$i][$j] . '</td>';
}
echo '</tr>';
}
echo '</table>';
echo "Indeksy liczb parzystych:";
foreach ($maxIndexes as $index) {
echo "(" . $index[0] . ", " . $index[1] . ") ";
}
echo '</div>';
} else {
echo 'Dane wejściowe nie są poprawne! Sprawdź wymiary, liczbę wartości lub czy wszystkie są liczbami.';
}
echo '</div>';
}
?>
</body>
</html>

View File

@@ -0,0 +1,300 @@
/* === UNIVERSAL SCHOOL TEMPLATE CSS (BLACK & WHITE EDITION) === */
/* clean, modern, and copy-paste friendly for all projects */
/* === RESET === */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* === VARIABLES === */
:root {
--accent: #000;
--border: #000;
--bg: #fff;
--bg-alt: #f7f7f7;
--text: #111;
--shadow: rgba(0, 0, 0, 0.15) 3px 3px 6px;
--radius: 1em;
--max-width: 1300px;
}
/* === PAGE === */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Verdana, sans-serif;
background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
color: var(--text);
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
line-height: 1.6;
}
/* === HEADER === */
header {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 20px 30px;
box-shadow: var(--shadow);
background: var(--bg);
width: 95%;
max-width: var(--max-width);
text-align: center;
margin-top: 25px;
transition: box-shadow 0.3s ease, transform 0.2s ease;
}
header:hover {
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
transform: translateY(-2px);
}
header h1 {
font-size: 2.2rem;
}
header h2 {
margin-top: 0.5rem;
font-weight: 400;
font-size: 1.1rem;
color: #444;
}
/* === BOX === */
.box {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 25px 35px;
margin-top: 25px;
background: var(--bg);
box-shadow: var(--shadow);
width: 95%;
max-width: var(--max-width);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box:hover {
transform: translateY(-2px);
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
}
/* === TEXT ELEMENTS === */
p {
margin-bottom: 1rem;
}
.box > p:last-child {
margin-bottom: 0;
}
h1, h2, h3, h4 {
margin-bottom: 0.5rem;
font-weight: 600;
}
a {
color: #000;
text-decoration: underline;
font-weight: 500;
}
a:hover {
opacity: 0.7;
}
/* === LISTS === */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
}
li {
margin-bottom: 0.4rem;
}
/* === TABLES === */
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background: var(--bg);
border: 2px solid var(--border);
border-radius: 0.6em;
overflow: hidden;
box-shadow: var(--shadow);
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid #ccc;
text-align: center;
}
th {
background: var(--bg-alt);
font-weight: bold;
text-align: left;
}
tr:hover {
background: #f2f2f2;
}
/* === FORMS === */
form {
display: flex;
flex-direction: column;
gap: 1.4rem;
}
.box:has(> form) {
padding: 35px 35px;
}
fieldset {
border: 2px solid var(--border);
border-radius: 0.8em;
padding: 1.2rem 1.5rem;
background: var(--bg-alt);
}
legend {
font-weight: bold;
color: #000;
padding: 0 0.4rem;
font-size: 1.05rem;
}
label {
font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
textarea,
select {
width: 100%;
font-size: 1rem;
margin-top: 6px;
margin-bottom: 8px;
border: 2px solid var(--border);
border-radius: 0.5em;
padding: 0.4rem 0.5rem;
transition: all 0.2s ease;
background: var(--bg);
}
textarea {
resize: vertical;
min-height: 100px;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border-color: #000;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
background: #f9f9f9;
}
input[type="radio"],
input[type="checkbox"] {
accent-color: #000;
transform: scale(1.2);
margin-right: 0.3rem;
}
/* === BUTTONS === */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
padding: 10px 20px;
border: 2px solid var(--border);
border-radius: 0.5em;
font-weight: bold;
font-size: 1rem;
background: linear-gradient(180deg, #fff 0%, #f2f2f2 100%);
cursor: pointer;
transition: all 0.2s ease;
align-self: flex-start;
}
button {
width: 100%;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
background: #eaeaea;
box-shadow: rgba(0, 0, 0, 0.25) 3px 3px 6px;
transform: translateY(-2px);
}
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
transform: translateY(0);
box-shadow: rgba(0, 0, 0, 0.15) 1px 1px 3px;
background: #f7f7f7;
}
/* === HR, CODE, ETC. === */
hr {
border: 0;
border-top: 2px solid var(--border);
margin: 1.5rem 0;
}
img {
max-width: 100%;
border-radius: 0.5em;
}
code, pre {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 0.4em;
padding: 0.3em 0.5em;
font-family: "Courier New", monospace;
}
pre {
padding: 1em;
overflow-x: auto;
}
/* === RESPONSIVE === */
@media (max-width: 900px) {
header, .box {
width: 95%;
padding: 20px;
}
button {
width: 100%;
}
textarea {
width: 100%;
}
}
@media (max-width: 600px) {
header h1 {
font-size: 1.7rem;
}
header h2 {
font-size: 0.95rem;
}
}

View File

@@ -0,0 +1,107 @@
<?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>Z99 - podzielne przez 3 i 5</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z99</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>Napisz program, który wczytuje liczby całkowite do tablicy o wymiarach n x m i wyświetla wskaźniki liczb podzielnych jednocześnie przez 3 i 5 (np. 15, 30). Użytkownik podaje n i m oraz wprowadza liczby do komponentu textarea oddzielone przecinkami. Program powinien zweryfikować, czy n i m są liczbami całkowitymi, czy podane wartości są liczbami całkowitymi, czy ich liczba zgadza się z n x m, a następnie wyświetlić tablicę i indeksy (w formacie [wiersz][kolumna]) wszystkich liczb podzielnych przez 3 i 5.</p>
<h3>Wskazówki dla ucznia:</h3>
<ul>
<li>Sprawdź, czy n i m są liczbami całkowitymi (is_numeric() i is_int() po konwersji).</li>
<li>Użyj explode(), aby rozdzielić ciąg z textarea na tablicę liczb na podstawie przecinków.</li>
<li>Zweryfikuj, czy każda wartość jest liczbą całkowitą za pomocą is_numeric() i sprawdzenia, czy po konwersji na int nie traci wartości dziesiętnej.</li>
<li>Przekształć jednowymiarową tablicę na dwuwymiarową, rozdzielając ją na wiersze po m elementów.</li>
<li>Przeszukaj tablicę dwuwymiarową pętlami i sprawdź podzielność przez 3 i 5 za pomocą operatora % (liczba musi dawać resztę 0 dla obu).</li>
<li>Zabezpiecz dane wejściowe za pomocą htmlspecialchars() przy pobieraniu, aby chronić przed XSS.</li>
</ul>
</div>
<div class="box">
<form action="index.php" method="post">
<fieldset>
<legend>Wymiary tablicy</legend>
<label for="n">Liczba wierszy (n):</label>
<input type="number" name="n" id="n" max="100" min="0" required>
<label for="m">Liczba kolumn (m):</label>
<input type="number" name="m" id="m" max="100" min="0" required>
</fieldset>
<fieldset>
<legend>Wartości tablicy (liczby całkowite oddzielone przecinkami):</legend>
<label for="values"></label>
<textarea name="values" id="values" cols="30" rows="10" placeholder="np. 1, 2, 3, 4"></textarea>
</fieldset>
<button type="submit">Wyślij</button>
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$nInput = htmlspecialchars($_POST['n']);
$mInput = htmlspecialchars($_POST['m']);
$valuesInput = htmlspecialchars($_POST['values']);
$isValidDimensions = is_numeric($nInput) && is_numeric($mInput) &&
(int)$nInput == $nInput &&
(int)$mInput == $mInput &&
(int)$nInput > 0 &&
(int)$mInput > 0;
$n = (int)$nInput;
$m = (int)$mInput;
$values = array_map('trim', explode(',', $valuesInput));
$count = count($values);
$isCountValid = $count === ($n*$m);
$areAllValuesValid = true;
foreach ($values as $value) {
if (!is_numeric($value)) { $areAllValuesValid = false; }
else { $value = (int)$value;}
}
echo '<div class="box">';
if ($areAllValuesValid && $isValidDimensions && $isCountValid) {
$values2d = array_chunk($values, $m);
$maxIndexes = array();
for ($i = 0; $i < $n; $i++) {
for ($j = 0; $j < $m; $j++) {
if ($values2d[$i][$j] % 3 == 0 && $values2d[$i][$j] % 5 == 0) {
$maxIndexes[] = array($i, $j);
}
}
}
echo "Wymiary tablicy: n = $n, m = $m<br>";
echo "Wprowadzone liczby: ";
echo implode(', ', $values);
echo "<br>Tablica $n x $m:";
echo '<table>';
for ($i = 0; $i < $n; $i++) {
echo '<tr>';
for ($j = 0; $j < $m; $j++) {
echo '<td>' . $values2d[$i][$j] . '</td>';
}
echo '</tr>';
}
echo '</table>';
echo "Indeksy liczb podzielnych przez 3 i 5:";
foreach ($maxIndexes as $index) {
echo "(" . $index[0] . ", " . $index[1] . ") ";
}
echo '</div>';
} else {
echo 'Dane wejściowe nie są poprawne! Sprawdź wymiary, liczbę wartości lub czy wszystkie są liczbami.';
}
echo '</div>';
}
?>
</body>
</html>

View File

@@ -0,0 +1,300 @@
/* === UNIVERSAL SCHOOL TEMPLATE CSS (BLACK & WHITE EDITION) === */
/* clean, modern, and copy-paste friendly for all projects */
/* === RESET === */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* === VARIABLES === */
:root {
--accent: #000;
--border: #000;
--bg: #fff;
--bg-alt: #f7f7f7;
--text: #111;
--shadow: rgba(0, 0, 0, 0.15) 3px 3px 6px;
--radius: 1em;
--max-width: 1300px;
}
/* === PAGE === */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Verdana, sans-serif;
background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
color: var(--text);
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
line-height: 1.6;
}
/* === HEADER === */
header {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 20px 30px;
box-shadow: var(--shadow);
background: var(--bg);
width: 95%;
max-width: var(--max-width);
text-align: center;
margin-top: 25px;
transition: box-shadow 0.3s ease, transform 0.2s ease;
}
header:hover {
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
transform: translateY(-2px);
}
header h1 {
font-size: 2.2rem;
}
header h2 {
margin-top: 0.5rem;
font-weight: 400;
font-size: 1.1rem;
color: #444;
}
/* === BOX === */
.box {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 25px 35px;
margin-top: 25px;
background: var(--bg);
box-shadow: var(--shadow);
width: 95%;
max-width: var(--max-width);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box:hover {
transform: translateY(-2px);
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
}
/* === TEXT ELEMENTS === */
p {
margin-bottom: 1rem;
}
.box > p:last-child {
margin-bottom: 0;
}
h1, h2, h3, h4 {
margin-bottom: 0.5rem;
font-weight: 600;
}
a {
color: #000;
text-decoration: underline;
font-weight: 500;
}
a:hover {
opacity: 0.7;
}
/* === LISTS === */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
}
li {
margin-bottom: 0.4rem;
}
/* === TABLES === */
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background: var(--bg);
border: 2px solid var(--border);
border-radius: 0.6em;
overflow: hidden;
box-shadow: var(--shadow);
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid #ccc;
text-align: center;
}
th {
background: var(--bg-alt);
font-weight: bold;
text-align: left;
}
tr:hover {
background: #f2f2f2;
}
/* === FORMS === */
form {
display: flex;
flex-direction: column;
gap: 1.4rem;
}
.box:has(> form) {
padding: 35px 35px;
}
fieldset {
border: 2px solid var(--border);
border-radius: 0.8em;
padding: 1.2rem 1.5rem;
background: var(--bg-alt);
}
legend {
font-weight: bold;
color: #000;
padding: 0 0.4rem;
font-size: 1.05rem;
}
label {
font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
textarea,
select {
width: 100%;
font-size: 1rem;
margin-top: 6px;
margin-bottom: 8px;
border: 2px solid var(--border);
border-radius: 0.5em;
padding: 0.4rem 0.5rem;
transition: all 0.2s ease;
background: var(--bg);
}
textarea {
resize: vertical;
min-height: 100px;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border-color: #000;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
background: #f9f9f9;
}
input[type="radio"],
input[type="checkbox"] {
accent-color: #000;
transform: scale(1.2);
margin-right: 0.3rem;
}
/* === BUTTONS === */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
padding: 10px 20px;
border: 2px solid var(--border);
border-radius: 0.5em;
font-weight: bold;
font-size: 1rem;
background: linear-gradient(180deg, #fff 0%, #f2f2f2 100%);
cursor: pointer;
transition: all 0.2s ease;
align-self: flex-start;
}
button {
width: 100%;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
background: #eaeaea;
box-shadow: rgba(0, 0, 0, 0.25) 3px 3px 6px;
transform: translateY(-2px);
}
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
transform: translateY(0);
box-shadow: rgba(0, 0, 0, 0.15) 1px 1px 3px;
background: #f7f7f7;
}
/* === HR, CODE, ETC. === */
hr {
border: 0;
border-top: 2px solid var(--border);
margin: 1.5rem 0;
}
img {
max-width: 100%;
border-radius: 0.5em;
}
code, pre {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 0.4em;
padding: 0.3em 0.5em;
font-family: "Courier New", monospace;
}
pre {
padding: 1em;
overflow-x: auto;
}
/* === RESPONSIVE === */
@media (max-width: 900px) {
header, .box {
width: 95%;
padding: 20px;
}
button {
width: 100%;
}
textarea {
width: 100%;
}
}
@media (max-width: 600px) {
header h1 {
font-size: 1.7rem;
}
header h2 {
font-size: 0.95rem;
}
}