-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimplementacja.php
More file actions
36 lines (36 loc) · 862 Bytes
/
implementacja.php
File metadata and controls
36 lines (36 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
$stos = [3, 4, 5, 9, 2];
for (;;) {
echo "Menu:\n";
echo "1:Wyswietls stos\n";
echo "2:Dodaj do stosu\n";
echo "3:Usun ze stosu\n";
echo "4:posortuj stos\n";
echo "5:koniec\n";
$input = readline("co mam zrobic:");
switch ($input) {
case 1:
if (count($stos) == 0) {
echo "stos jest pusty";
} else {
print_r($stos);
}
break;
case 2:
$number = readline("co dodać(tylko liczby):");
array_unshift($stos, $number);
break;
case 3:
array_pop($stos);
break;
case 4:
sort($stos);
print_r($stos);
break;
case 5:
exit();
break;
default:
echo "nie prawidłowa opcja";
}
}