วันอาทิตย์ที่ 25 ตุลาคม พ.ศ. 2558

[LAB6] Classroom #2D_Array

def setup():
   first_floors = [26, 32, 18, 17]
   second_floors = [16, 15, 24, 31]
   third_floors = [19, 26, 21, 30]
   buildings = [first_floors,second_floors,third_floors]
   #total_chairs(buildings)
   #find_max_floor(buildings)
   find_max_room(buildings)

def total_chairs(buildings):
   i = 0
   total = 0
   while(i < len(buildings)):
         choose = 0
         while(choose < len(buildings[i])):
            total = total + buildings[i][choose]
            choose = choose + 1
         i = i + 1
   print(total)
 
def find_max_floor(buildings):
   i = 0
   max_floor = 0
   total = 0
   ref = 0
   while(i < len(buildings)):
      choose = 0
      while(choose < len(buildings[i])):
            total = total + buildings[i][choose]
            choose = choose + 1
      if(total > ref):
         ref = total
         max_floor = i
      i = i + 1
   print(max_floor)
 
def find_max_room(buildings):
   i = 0
   ref = buildings[0][0]
   while(i < len(buildings)):
      choose = 0
      while(choose < len(buildings[i])):
         if(buildings[i][choose] > ref):
            ref = buildings[i][choose]
         choose = choose + 1
      i = i + 1
   i = 0
   while(i < len(buildings)):
      choose = 0
      while(choose < len(buildings[i])):
         if(ref == buildings[i][choose]):
            print("[",i,"][",choose,"]")
         choose = choose + 1
      i = i + 1
 
setup()

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

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