วันจันทร์ที่ 19 ตุลาคม พ.ศ. 2558

Display student records, sorted by age, use insertion sort.

def setup():
   name = ["Gun","Rit","Frame","Coffee","Ice","Boat"]
   ID = [32075,32078,32080,32057,32087,33653]
   age = [26,25,19,17,18,16]
   weight = [80,75,58.2,60,65,55]
   height = [174,170,173,165,168,163]
   i = 0
   sort(name,ID,age,weight,height)
   while(i<len(weight)):
      display(name,ID,age,weight,height,i)
      i += 1

def display(n,I,a,w,h,i):  
      print(n[i])
      print("ID =",I[i])
      print("age =",a[i])
      print("weight =",w[i])
      print("height =",h[i])
      print()    
   
def sort(n,I,a,w,h):
   i = 1
   while(i<len(a)):
      value_a = a[i]
      value_n = n[i]
      value_I = I[i]
      value_w = w[i]
      value_h = h[i]
      j = i
      while(j>0 and a[j-1] > value_a):
         a[j] = a[j-1]
         n[j] = n[j-1]
         I[j] = I[j-1]
         w[j] = w[j-1]
         h[j] = h[j-1]
         j = j - 1
      a[j] = value_a
      n[j] = value_n
      I[j] = value_I
      w[j] = value_w
      h[j] = value_h
      i += 1
   
setup()

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

Link Video Presentation Resort Managemant System Project.

Video Presentation Resort Managemant System Project. จัดทำโดย พากษ์เสียง: คุณาสิน  ทองมณี  5801012620011 ลำดับภาพ: สุพิชชา  ศรีศิริ...