love

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

Lab6 - Find index of the floor(s) with maximum number of chairs (in the building)

def setup():
   floor_1 = [43 ,55 ,48]
   floor_2 = [33 ,20 ,25 ,38]
   floor_3 = [38 ,45 ,42 ,44 ,53]
   floor_4 = [50 ,50]
   building = [floor_1,floor_2,floor_3,floor_4]
   total_chair(building)
 
def total_chair(b):
   i = 0
   chair = 0
   chair_max = 0
   i_m = 0
   while(i<len(b)):
      a = 0
      while(a<len(b[i])):
         chair = b[i][a]
         if(chair>chair_max):
            chair_max = chair
            i_m = i+1
         a = a +1
      i = i+1
   print("Chair number in this building is ",chair_max," Floor ",i_m)
 
setup()
 

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

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