floor1=[50,55,49,40,50]
floor2=[70,55,100,1000]
floor3=[49,53,53,60]
building=[floor1,floor2,floor3]
print('this building have',find_num_total_chair(building),'chair')
print('the floor which have maximum chair is floor',find_max_chair_in_floor(building))
def find_num_total_chair(b):
room = 0
floor = 0
total_chair = 0
while(floor<len(b)):
while(room<len(b[floor])):
total_chair+=b[floor][room]
room+=1
room = 0
floor+=1
return total_chair
def find_max_chair_in_floor(b):
room = 0
floor = 0
total_chair = 0
total_of_max_chair = 0
max_chair_floor = 0
while(floor<len(b)):
while(room<len(b[floor])):
total_chair+=b[floor][room]
room+=1
if(total_chair>total_of_max_chair):
total_of_max_chair = total_chair
max_chair_floor = floor+1
room = 0
total_chair = 0
floor+=1
return max_chair_floor
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น