love

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

Lab6 - Find indices of the room(s) with maximum number of chairs (in the building)

def setup():
   floor_1 = [43 ,55 ,48]
   floor_2 = [55 ,20 ,55 ,38]
   floor_3 = [38 ,55 ,42 ,55 ,53]
   floor_4 = [50 ,55]
   building = [floor_1,floor_2,floor_3,floor_4]
   total_chair(building)
 
def total_chair(b):
   i = 0
   chair = 0
   chair_max = 0
   while(i<len(b)):
      a = 0
      while(a<len(b[i])):
         chair = b[i][a]
         if(chair>chair_max):
            chair_max = chair
         a = a +1
      i = i+1
   i = 0
   chair = 0
   i_m = 0
   i_r = 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
            i_r = a+1
            print("Chair number in this building is ",chair_max," Floor ",i_m , "Room" ,i_r)
         a = a +1
      i = i+1
setup()
 

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

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