This commit is contained in:
jakub
2025-05-23 20:04:55 +02:00
parent 0fb58def1a
commit 37f309f424
7 changed files with 396 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<!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>T54.2 - zastosowanie funkcji</title>
<link rel="stylesheet" href="../style.css">
</head>
<body>
<header>
<h1>Zadanie T54.2</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>
Zadanie T542 <br><br>
Napisz funkcję, której wynikiem będzie podniesienie wartości przekazanego jej poprzez referencję argumentu do potęgi przekazanej również jako argument. Funkcja zwraca wartość i wyświetla wynik w postaci (np. dla wartości 2 i 3): <br><br>
x = 2 <br>
y = 3 <br>
x<sup>y</sup>=2<sup>3</sup>=8 <br><br>
trochę musicie pokombinować, aby wynik był wyświetlany na stronie w postaci takiego wyrażenia ;)
</p>
</div>
<div class="box">
<form action="index.php" method="post">
<label for="x">Wprowadź liczbę X:</label><br>
<input type="number" name="x" id="x"><br>
<label for="y">Wprowadź liczbę Y:</label><br>
<input type="number" name="y" id="y"><br>
<button type="submit">Wyślij</button>
</form>
</div>
<?php
function potega(&$x, $y): void
{
$x = $x ** $y;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo "<div class='box'>";
$x = (int)$_POST['x'];
$y = (int)$_POST['y'];
$wynik = "x<sup>y</sup> = $x<sup>$y</sup> = ";
potega($x, $y);
$wynik .= $x;
echo $wynik;
echo "</div>";
}
?>
</body>
</html>