-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbubble_sort_algoritması.py
More file actions
33 lines (26 loc) · 946 Bytes
/
bubble_sort_algoritması.py
File metadata and controls
33 lines (26 loc) · 946 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
'''
BENZERSİZ SAYILARDAN OLUŞAN DİZİYİ BUBBLE SORT ALGORİTMASI İLE SIRALAMA
'''
import random
uzunluk = int(input('UZUNLUK SAYISI GİRİNİZ...:'))
dizi = []
while(True):
rastGele = random.randint(0, uzunluk * 10)
if rastGele in dizi:
pass
else:
dizi.append(rastGele)
if dizi.__len__() == uzunluk:
break
print('*********************************************************************************')
print('DİZİ UZUNLUĞU...:'+ str(uzunluk))
print('RANDOM SEÇİLEN BAŞLANGIÇ DİZİSİ...:', dizi)
for i in range(uzunluk):
for j in range(uzunluk - 1):
if dizi[j] > dizi[j + 1]:
A = dizi[j]
dizi[j] = dizi[j + 1]
dizi[j + 1] = A
print('*********************************************************************************')
print('SIRALAMA SONUCU...:' ,dizi)
print('*********************************************************************************')