SelectionSort

This commit is contained in:
Rsclub2 2 2022-06-16 14:26:56 +02:00
parent 9f5acc3f58
commit 9e928bbec7
2 changed files with 23 additions and 0 deletions

View 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)

View 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)
'''