Created
March 29, 2015 09:36
-
-
Save ozgurkaracam/27a2250927533b3bd3f0 to your computer and use it in GitHub Desktop.
sıralı iki diziyi birleştiren ve ortak elemanlarını bulan fonksiyon.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def birlestir(dizi1,dizi2): | |
adizi=[] | |
i=0 | |
j=0 | |
ortakeleman=[] | |
while i<len(dizi1) and j<len(dizi2): | |
if dizi1[i]<dizi2[j]: | |
adizi.append(dizi1[i]) | |
i=i+1 | |
else: | |
if dizi1[i]>dizi2[j]: | |
adizi.append(dizi2[j]) | |
j=j+1 | |
else: | |
adizi.append(dizi1[i]) | |
ortakeleman.append(dizi1[i]) | |
i=i+1 | |
j=j+1 | |
while i<len(dizi1): | |
adizi.append(dizi1[i]) | |
i=i+1 | |
while j<len(dizi2): | |
adizi.append(dizi2[j]) | |
j=j+1 | |
print ("birleştirilmişt dizi :", adizi) | |
print ("ortak elemanlar :",ortakeleman | |
birlestir([3,5,8,10],[1,2,3,4,5,8,9,13,18]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment