klassenarbeit 2 progp vom 15.1.12025

This commit is contained in:
danielvici123
2025-01-15 13:14:16 +01:00
parent 2d0894a8f3
commit 1507b7d590
5 changed files with 171 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
<?php
function sucheMinBelegung(zimmerliste: Zimmer[], weiblich: boolean): int {
function sucheMinBelegung($zimmerliste, $weiblich) {
$minIndex = -1;
$belegung = 1.0;
$minBelegung = 1;

View File

@@ -0,0 +1,34 @@
<?php
// #################
// # NAME #
// # DANIEL CWIKLA #
// #################
echo "<h2>Größter Teiler</h2>";
$zahl_a = 1071;
$zahl_b = 1029;
function ggt(int $a, int $b):int {
$ausgabe = "NIX";
$gr_rest = array();
if ($a > $b) {
$rest = $b;
echo "rechnen...<br>";
while($rest != 0){
$rest = $a % $rest;
//echo $rest."<br>";
$gr_rest[] = $rest;
}
array_pop($gr_rest);
echo "Der größte Teiler ist: " . $gr_rest[count($gr_rest)-1];
echo "<br> Zahlen: ".$a." und ".$b ;
}else {
echo"a darf nicht kleiner als b sein!<br>";
$groester_teiler = -1;
echo "Der größte Teiler ist: $groester_teiler";
echo "<br> Zahlen: ".$a." und ".$b ;
}
}
ggt($zahl_a, $zahl_b);
?>

View File

@@ -0,0 +1,31 @@
<?php
// #################
// # NAME #
// # DANIEL CWIKLA #
// #################
echo "<h2>Prüfsumme</h2>";
$zahl_vorgabe = 4581072;
function idValidator($id):int {
$faktor = 1;
$i = -1;
echo "id".$id;
$arr_id = str_split($id,1);
while( $i < (count($arr_id))){
$i++;
echo "<br>".$i+1 .". ".$arr_id[$i];
if ($i == 2 or $i == 5){
$faktor = 3;
}else {
$faktor = 1;
}
$arr_faktor = array($faktor * $arr_id[$i]);
print_r($arr_faktor);
$ps = $ps+ $arr_faktor[$i];
echo ", $ps";
}
echo"<br>---<br>$ps";
}
idValidator($zahl_vorgabe);
?>

View File

@@ -0,0 +1,6 @@
<?php
$number = $array(3,5,1,2); // index 0 = 3, index 1 = 5, index 2 = 1, index 3 = 2
sort($number); // => $number = array(1,2,3,5); index: 0 = 1, index 1 = 2, index 2 = 3, index 3 = 5
asort($number); // => $number = array(1,2,3,4,5); index: 0 = 2, index 1 = 1, index 2 = 5, index 3 = 3
?>