Initial commit
This commit is contained in:
commit
a1ddfdb7c0
14 changed files with 599 additions and 0 deletions
BIN
exercise_1/1_Übungsblatt_Nr_2-1.pdf
Normal file
BIN
exercise_1/1_Übungsblatt_Nr_2-1.pdf
Normal file
Binary file not shown.
BIN
exercise_1/2026SS-TheoInf-HAB01.pdf
Normal file
BIN
exercise_1/2026SS-TheoInf-HAB01.pdf
Normal file
Binary file not shown.
28
exercise_1/HAB01-A3-Template.TXT
Normal file
28
exercise_1/HAB01-A3-Template.TXT
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Gefordert: kommentiertes WHILE-Programm
|
||||
# Sie können weitere Hilfsfunktionen verwenden!
|
||||
# Namen:
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
########## HAUPTFUNKTIONEN ########## (Namen und Signatur nicht ändern!)
|
||||
# Wir nutzen Python Type hints um die Eingabe-/Ausgabetypen anzuzeigen. In WHILE/LOOP-Programmen wegen des Syntax-Checkers als Kommentar zu finden.
|
||||
|
||||
def divtwo(x): # divtwo(x: int) -> int
|
||||
# ...
|
||||
return # ...
|
||||
|
||||
|
||||
def bin(n): # bin(n: int)
|
||||
if(n <= 0):
|
||||
print(0)
|
||||
else:
|
||||
# ...
|
||||
# hier könnte divtwo(...) aufgerufen werden
|
||||
# ...
|
||||
# hier könnte print(...) aufgerufen werden
|
||||
# ...
|
||||
# Keine Ausgabe notwendig, Ausgabe findet über print statt
|
||||
return -1
|
||||
|
||||
|
||||
11
exercise_1/task2.py
Normal file
11
exercise_1/task2.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
def g(x):
|
||||
return (x + x)
|
||||
|
||||
def f(x):
|
||||
if (x < 0):
|
||||
d = 0
|
||||
if (x == 0):
|
||||
d = 1
|
||||
else:
|
||||
d = g(f((x - 1)))
|
||||
return d
|
||||
23
exercise_1/task3-l.py
Normal file
23
exercise_1/task3-l.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
def divtwo(x):
|
||||
y=0
|
||||
z=0
|
||||
if (x>=0):
|
||||
z=x
|
||||
while ((z-y)>1):
|
||||
z=(z-1)
|
||||
y=(y+1)
|
||||
return y
|
||||
|
||||
def bin(x):
|
||||
z=0
|
||||
y=1
|
||||
if (x>0):
|
||||
y=divtwo(x)
|
||||
z=(x-(y+y))
|
||||
print(z)
|
||||
x=y
|
||||
else:
|
||||
print(0)
|
||||
return 0
|
||||
|
||||
print(bin(2))
|
||||
25
exercise_1/task3.py
Normal file
25
exercise_1/task3.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
def divtwo(x):
|
||||
if (x >= 0):
|
||||
a = 0
|
||||
z = 0
|
||||
# Wie oft passt die 2 in x
|
||||
while (a <= x):
|
||||
a = (a + 2)
|
||||
z = (z + 1)
|
||||
z = (z - 1)
|
||||
else:
|
||||
z = 0
|
||||
return z
|
||||
|
||||
def bin(n):
|
||||
if (n == 0):
|
||||
print(0)
|
||||
if (n > 0):
|
||||
a = n
|
||||
# Das Verfahren zur Bestimmung der Binärdarstellung aus der Vorlesung
|
||||
while (a > 0):
|
||||
q = divtwo(a) # Quotient
|
||||
r = (a - (q + q)) # Rest berechnen
|
||||
a = q # Nächste Zeile im Verfahren
|
||||
print(r)
|
||||
return 0
|
||||
25
exercise_1/task3.txt
Normal file
25
exercise_1/task3.txt
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
def divtwo(x):
|
||||
if (x >= 0):
|
||||
a = 0
|
||||
z = 0
|
||||
# Wie oft passt die 2 in x
|
||||
while (a <= x):
|
||||
a = (a + 2)
|
||||
z = (z + 1)
|
||||
z = (z - 1)
|
||||
else:
|
||||
z = 0
|
||||
return z
|
||||
|
||||
def bin(n):
|
||||
if (n == 0):
|
||||
print(0)
|
||||
if (n > 0):
|
||||
a = n
|
||||
# Das Verfahren zur Bestimmung der Binärdarstellung aus der Vorlesung
|
||||
while (a > 0):
|
||||
q = divtwo(a) # Quotient
|
||||
r = (a - (q + q)) # Rest berechnen
|
||||
a = q # Nächste Zeile im Verfahren
|
||||
print(r)
|
||||
return 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue