SelectionSort
This commit is contained in:
parent
9f5acc3f58
commit
9e928bbec7
9
3. Übungen/16.06.2022/Insertionsort.py
Normal file
9
3. Übungen/16.06.2022/Insertionsort.py
Normal file
@ -0,0 +1,9 @@
|
||||
data=[9,5,1,4,3]
|
||||
for step in range (1, len(data)):
|
||||
key=data[step]
|
||||
j=step-1
|
||||
while j>=0 and key < data[j]:
|
||||
data[j+1]=data[j]
|
||||
j=j-1
|
||||
data[j+1]=key
|
||||
print(data)
|
14
3. Übungen/16.06.2022/wiederholung_array.py
Normal file
14
3. Übungen/16.06.2022/wiederholung_array.py
Normal file
@ -0,0 +1,14 @@
|
||||
# Wiederholung Array/Feld
|
||||
|
||||
zahlen=[4,6,3,9,12,1,8] # Array wird erzeugt, hat bereits 7 Elemente
|
||||
|
||||
# Tausch zweier Werte aus dem Array (4 und 6)
|
||||
zahlen[0],zahlen[1]=zahlen[1],zahlen[0]
|
||||
print(zahlen)
|
||||
|
||||
''' # Summe des Arrays
|
||||
summe=0
|
||||
for i in range(7):
|
||||
summe=summe+zahlen[i]
|
||||
print(summe)
|
||||
'''
|
Loading…
x
Reference in New Issue
Block a user