age = [35,19,18,20,19,31]
print(age)
print('Display the age that less than 30 years old by sort age')
sort_age(age)
show_age(age)
def show_age(age):
count = 0
find_age = 30
while(count<len(age)):
if(age[count]<find_age):
print(age[count])
count = count + 1
def sort_age(age):
index =1
while(index<len(age)):
new_age =age[index]
index2=index
while(index2>0 and age[index2-1]>new_age):
age[index2]=age[index2-1]
index2=index2-1
age[index2]=new_age
index=index+1
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น