Re: Die üblichen Übungen

Image Screenshot_20240303_153122

<?php
session_start ();
?>

<form method="POST" action="./form20240303.php">
<input type="text" name="form2024030301"></input>
<input type="submit"></input>
</form>

<?php
setcookie ("form2024030302", "Ich bin das erste Cookie", time () + 3600);

echo session_id () . "<br>n";

echo htmlentities (\$_COOKIE ["form2024030302"]) . "<br>n";
echo htmlentities (\$_COOKIE ["form2024030303"]) . "<br>n";
echo htmlentities (\$_POST ["form2024030301"]) . "<br>n";

session_destroy ();
?>

POST http://localhost/mysql20240217/20240303/form20240303.php HTTP/1.1
host: localhost
Cookie: form2024030303=Hallo, ich bin das zweite Cookie
Content-Length: 41
Content-Type: application/x-www-form-urlencoded

form2024030301=Ich bin das Datum Nummer 1

Trying ::1...
Connected to localhost.
Escape character is '\^]'.
HTTP/1.1 200 OK
Date: Sun, 03 Mar 2024 14:30:50 GMT
Server: Apache/2.4.57 (Debian)
Set-Cookie: PHPSESSID=0019v7jm8159tuotkprdhn21n2; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: form2024030302=Ich%20bin%20das%20erste%20Cookie; expires=Sun, 03 Mar 2024 15:30:50 GMT; Max-Age=3600
Vary: Accept-Encoding
Content-Length: 243
Content-Type: text/html; charset=UTF-8


<form method="POST" action="./form20240303.php">
<input type="text" name="form2024030301"></input>
<input type="submit"></input>
</form>

0019v7jm8159tuotkprdhn21n2<br>
<br>
Hallo, ich bin das zweite Cookie<br>
Ich bin das Datum Nummer 1<br>

<?php
session_start ();

include ("/home/david/mysqldata.php");

\$db = new PDO ("mysql: host=localhost", \$MYSQL_USER, \$MYSQL_PASSWORD);

\$sql = "CREATE DATABASE mysql20240303" . session_id () . "; ";
\$db->query (\$sql);

\$sql = "USE mysql20240303" . session_id () . "; ";
\$db->query (\$sql);

\$sql = "CREATE TABLE a (x1 INTEGER, x2 INTEGER); ";
\$db->query (\$sql);

\$sql = "CREATE TABLE b (y1 INTEGER, y2 INTEGER); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (0, 0); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (0, 1); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (1, 0); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (1, 1); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (7, 4); ";
\$db->query (\$sql);

\$sql = "INSERT INTO b (y1, y2) VALUES (0, 1); ";
\$db->query (\$sql);

\$sql = "INSERT INTO b (y1, y2) VALUES (4, 7); ";
\$db->query (\$sql);

\$sql = "SELECT x1, x2 FROM a; ";
\$stmt = \$db->query (\$sql);
echo "<br>n{";
while (\$row = \$stmt -> fetch ())
    echo "(" . \$row [0] . ", " . \$row [1] . "); ";
echo "}<br>n";

\$sql = "SELECT y1, y2 FROM b; ";
\$stmt = \$db->query (\$sql);
echo "<br>n{";
while (\$row = \$stmt -> fetch ())
    echo "(" . \$row [0] . ", " . \$row [1] . "); ";
echo "}<br>n";

\$sql = "SELECT x1, x2, y1, y2 FROM a LEFT JOIN b ON a.x1 = b.y2; ";
\$stmt = \$db->query (\$sql);
echo "<br>n{";
while (\$row = \$stmt -> fetch ())
    echo "(" . \$row [0] . ", " . \$row [1] . ", " . \$row [2] . ", " . \$row [3] . "); ";
echo "}<br>n";

\$sql = "DROP DATABASE mysql20240303" . session_id () . "; ";
\$db->query (\$sql);

session_destroy ();
?>

<br>
{(0, 0); (0, 1); (1, 0); (1, 1); (7, 4); }<br>
<br>
{(0, 1); (4, 7); }<br>
<br>
{(1, 0, 0, 1); (1, 1, 0, 1); (7, 4, 4, 7); (0, 0, , ); (0, 1, , ); }<br>

<?php
session_start ();

include ("/home/david/mysqldata.php");

\$db = new PDO ("mysql: host=localhost", \$MYSQL_USER, \$MYSQL_PASSWORD);

\$sql = "CREATE DATABASE qu20240303" . session_id () . "; ";
\$db->query (\$sql);

\$sql = "USE qu20240303" . session_id () . "; ";
\$db->query (\$sql);

\$sql = "CREATE TABLE a (x INTEGER); ";
\$db->query (\$sql);

\$sql = "CREATE TABLE b (x INTEGER); ";
\$db->query (\$sql);

\$sql = "CREATE TABLE c (x INTEGER); ";
\$db->query (\$sql);

for (\$i = 0;  \$i < 24;  \$i++) {
    \$sql = "INSERT INTO a (x) VALUES ("" . rand () % 28 . ""); ";
    \$sql .= "INSERT INTO b (x) VALUES ("" . rand () % 32 . ""); ";
    \$sql .= "INSERT INTO c (x) VALUES ("" . rand () % 64 . ""); ";
    \$db->query (\$sql);
}

\$sql = "SELECT x FROM (SELECT x FROM a UNION SELECT x FROM b) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (SELECT x FROM a UNION SELECT x FROM c) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (SELECT x FROM b UNION SELECT x FROM c) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM b) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM c) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (SELECT x FROM b INTERSECT SELECT x FROM c) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a UNION SELECT x FROM b) x
                INTERSECT
            SELECT x FROM c
    ) x;";
    \$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM c) x
                UNION
            SELECT x FROM (SELECT x FROM b INTERSECT SELECT x FROM c) x
    ) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a UNION SELECT x FROM c) x
                INTERSECT
            SELECT x FROM b
    ) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM b) x
                UNION
            SELECT x FROM (SELECT x FROM c INTERSECT SELECT x FROM b) x
    ) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM b UNION SELECT x FROM c) x
                INTERSECT
            SELECT x FROM a
    ) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM b INTERSECT SELECT x FROM a) x
                UNION
            SELECT x FROM (SELECT x FROM c INTERSECT SELECT x FROM c) x
    ) x;";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n";

\$sql = "DROP DATABASE qu20240303" . session_id () . "; ";
\$db->query (\$sql);

session_destroy ();
?>

23, 9, 25, 1, 2, 11, 22, 27, 16, 12, 5, 3, 19, 26, 7, 13, 18, 4, 14, 30, 21, 0, 10, 8, 28, 15, 29, <br>
23, 9, 25, 1, 2, 11, 22, 27, 16, 12, 5, 3, 19, 26, 7, 13, 18, 4, 14, 21, 61, 15, 37, 0, 51, 44, 36, 46, 35, 63, 40, 60, 47, <br>
12, 27, 30, 1, 26, 21, 25, 0, 10, 8, 28, 15, 29, 4, 19, 18, 14, 23, 13, 61, 37, 51, 44, 36, 46, 35, 63, 40, 60, 47, <br>
23, 25, 1, 27, 12, 19, 26, 13, 18, 4, 14, <br>
23, 27, 19, 26, 13, <br>
27, 26, 21, 0, 15, 19, 23, 13, <br>
23, 27, 19, 26, 13, 21, 0, 15, <br>
23, 27, 19, 26, 13, 21, 0, 15, <br>
23, 25, 1, 27, 12, 19, 26, 13, 18, 4, 14, 21, 15, 0, <br>
23, 25, 1, 27, 12, 19, 26, 13, 18, 4, 14, 21, 15, 0, <br>
12, 27, 1, 26, 25, 4, 19, 18, 14, 23, 13, <br>
12, 27, 1, 26, 25, 4, 19, 18, 14, 23, 13, 21, 61, 15, 37, 0, 51, 44, 36, 46, 35, 63, 40, 60, 47, <br>

#!/bin/bash

if [[ "\$1" == "David " \&amp;\&amp; "\$2" == "Vajda" ]]
then
    echo "Das bin ich"
elif [ "\$1" == "David Vajda" ]
then
    echo "Das bin ich"
elif [[ "\$1" == "David" \&amp;\&amp; -z "\$2" ]]
then
    echo "das koennte ich sein"
elif [[ "\$1" == "Vajda" ]]
then
    echo "das koennte ich sein"
elif [ -n "\$1" ]
then
    echo "das bin ich nicht"
else
    echo "Hallo Welt"
    i=0
    while [ \$i -lt 10 ]
    do
        echo "Hallo zum \$((\$i+1))"
        i=\$((\$i+1))
    done
    a=(Ich bin ein Array)
    a+=(und ich setzte es fort)
    i=0
    while [ \$i -lt 9 ]
    do
        echo "\${a[\$i]}"
        i=\$((\$i+1))
    done
    for s in "\${a[@]}"
    do
        echo "\$s"
    done
    l=\$(ls)
    for s in \$l
    do
        echo "\$s"
    done
fi

#!/bin/bash

/bin/bash myhello.sh "David" "Vajda"
/bin/bash myhello.sh "David Vajda"
/bin/bash myhello.sh "David"
/bin/bash myhello.sh "Vajda"
/bin/bash myhello.sh "Max Mustermann"
/bin/bash myhello.sh

das bin ich nicht
Das bin ich
das koennte ich sein
das koennte ich sein
das bin ich nicht
Hallo Welt
Hallo zum 1
Hallo zum 2
Hallo zum 3
Hallo zum 4
Hallo zum 5
Hallo zum 6
Hallo zum 7
Hallo zum 8
Hallo zum 9
Hallo zum 10
Ich
bin
ein
Array
und
ich
setzte
es
fort
Ich
bin
ein
Array
und
ich
setzte
es
fort
myhelloexec.sh
myhello.out
myhello.sh

Image 20240303_165611

Image 20240303_165616

Image 20240303_165623

1.) Rechne die Zahl in binaer Darstellung  in eine Dezimale Darstellung um
1010001101011010b 41818d
2.) Rechne die Zahl in dezimal darstellung in eine Binaerdarstellung um
533 0000001000010101
3.) Addiere die drei Zahlen schriftlich
            59524
+           57702
+           10652
-----------------
           127878
4.) Subtrahiere die letzten drei Zahlen schriftlich von der ersten schriftlich
            19267
-            3262
-           15725
-           12005
-----------------
           -11725
5.) Rechne die Zahl ins zweier komplement um, mit 8 Bit - und subtrahiere diese zahl von der ersten und rechne das Ergebnis nach dezimal
-65 -23 = -88
10111111 11101001 = 10101000
6.) Multipliziere die zwei Zahlen schriftlich
1937*34572 = 66965964
7.) Dividiere die zwei Zahlen schriftlich
44470/62047 = 0
8.) Errechne x Logarithmisch mit dem Taschenrechner
53278\^x = 378169858

Image 20240303_171311

Image 20240303_171316

Image Screenshot_20240303_173920

 0 0 0 0 0    1
 1 0 0 0 1    1
 2 0 0 1 0    1
 3 0 0 1 1    1
 4 0 1 0 0    0
 5 0 1 0 1    0
 6 0 1 1 0    0
 7 0 1 1 1    1
 8 1 0 0 0    0
 9 1 0 0 1    1
10 1 0 1 0    1
11 1 0 1 1    0
12 1 1 0 0    0
13 1 1 0 1    0
14 1 1 1 0    1
15 1 1 1 1    0


 0 0 0 0 0    1
 1 0 0 0 1    1
 2 0 0 1 0    1
 3 0 0 1 1    1
 7 0 1 1 1    1
 9 1 0 0 1    1
10 1 0 1 0    1
14 1 1 1 0    1


Gruppe 0:
 0 0 0 0 0    1
Gruppe 1:
 1 0 0 0 1    1
 2 0 0 1 0    1
Gruppe 2:
 3 0 0 1 1    1
 9 1 0 0 1    1
10 1 0 1 0    1
Gruppe 3:
 7 0 1 1 1    1
14 1 1 1 0    1

0:1         0 0 0 -
0:2         0 0 - 0
1:3         0 0 - 1
1:9         1 0 0 -
3:7         0 - 1 1
10:14       1 - 1 0



0:1         0 0 0 -
1:9         1 0 0 -
0:2         0 0 - 0
1:3         0 0 - 1
3:7         0 - 1 1
10:14       1 - 1 0


Gruppe 0:
0:2         0 0 - 0
Gruppe 1:
1:3         0 0 - 1

0:2:1:10        0 0 -

Gruppe 1:
1:9         1 0 0 -
Gruppe 0:
0:1         0 0 0 -

1:9:0:1         - 0 0 -

Gruppe 2:
3:7         0 - 1 1
10:14       1 - 1 0


0:2:1:10        0 0 - -
1:9:0:1         - 0 0 -
3:7             0 - 1 1
10:14           1 - 1 0


                0   1   2   3   7   9   10  14
0:2:1:10        *   *   *               *
1:9:0:1         *   *               *
3:7                         *   *
10:14                                   *   *

Alle notwendig


0:2:1:10        0 0 - -
1:9:0:1         - 0 0 -
3:7             0 - 1 1
10:14           1 - 1 0

    y <= (not x4 and not x3) or
            (not x2 and not x1) or
            (not x3 and x1 and x0) or
            (x3 and x1 and not x0);
    y <= (x2 or x0) and
            (x2 or x1) and
            (x3 or not x1 or not x0) and
            (not x3 or not x1 or x0);

library ieee;
use ieee.std_logic_1164.all;

entity quine20240303 is
port (
    x3, x2, x1, x0: in std_logic;
    y: out std_logic
);
end;

architecture behaviour of quine20240303 is
begin
    y <= (not x4 and not x3) or
            (not x2 and not x1) or
            (not x3 and x1 and x0) or
            (x3 and x1 and not x0);
end;

library ieee;
use ieee.std_logic_1164.all;

entity quine20240303testbench is
port (
    y: out std_logic
);
end;

architecture behaviour of quine20240303testbench is
    component quine20240303
    port (
        x3, x2, x1, x0: in std_logic;
        y: out std_logic
    );
    end component;
    signal x3, x2, x1, x0: std_logic;
begin
    q: quine20240303 PORT MAP (x3=>x3, x2=>x2, x1=>x1, x0=>x0, y=>y);

library ieee;
use ieee.std_logic_1164.all;

entity quine20240303 is
port (
    x3, x2, x1, x0: in std_logic;
    y: out std_logic
);
end;

architecture behaviour of quine20240303 is
begin
    y <= (not x3 and not x2) or
            (not x2 and not x1) or
            (not x3 and x1 and x0) or
            (x3 and x1 and not x0);
end;

library ieee;
use ieee.std_logic_1164.all;

entity quine20240303testbench is
port (
    y: out std_logic
);
end;

architecture behaviour of quine20240303testbench is
    component quine20240303
    port (
        x3, x2, x1, x0: in std_logic;
        y: out std_logic
    );
    end component;
    signal x3, x2, x1, x0: std_logic;
begin
    q: quine20240303 PORT MAP (x3=>x3, x2=>x2, x1=>x1, x0=>x0, y=>y);

    x0 <= '0' after 0 ns, '1' after 10 ns, '0' after 20 ns, '1' after 30 ns, '0' after 40 ns, '1' after 50 ns, '0' after 60 ns, '1' after 70 ns, '0' after 80 ns, '1' after 90 ns, '0' after 100 ns, '1' after 110 ns, '0' after 120 ns, '1' after 130 ns, '0' after 140 ns, '1' after 150 ns;

    x1 <= '0' after 0 ns, '0' after 10 ns, '1' after 20 ns, '1' after 30 ns, '0' after 40 ns, '0' after 50 ns, '1' after 60 ns, '1' after 70 ns, '0' after 80 ns, '0' after 90 ns, '1' after 100 ns, '1' after 110 ns, '0' after 120 ns, '0' after 130 ns, '1' after 140 ns, '1' after 150 ns;

    x2 <= '0' after 0 ns, '0' after 10 ns, '0' after 20 ns, '0' after 30 ns, '1' after 40 ns, '1' after 50 ns, '1' after 60 ns, '1' after 70 ns, '0' after 80 ns, '0' after 90 ns, '0' after 100 ns, '0' after 110 ns, '1' after 120 ns, '1' after 130 ns, '1' after 140 ns, '1' after 150 ns;

    x3 <= '0' after 0 ns, '0' after 10 ns, '0' after 20 ns, '0' after 30 ns, '0' after 40 ns, '0' after 50 ns, '0' after 60 ns, '0' after 70 ns, '1' after 80 ns, '1' after 90 ns, '1' after 100 ns, '1' after 110 ns, '1' after 120 ns, '1' after 130 ns, '1' after 140 ns, '1' after 150 ns;
end;

.text
	li \$t0, 0
	li \$t1, 32
	li \$t2, 4
l1:
	srl \$t1, \$t1, 1
	addi \$t0, \$t0, 1
	blt \$t0, \$t2, l1