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

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

def setup():
   one = [10, 20, 30, 40, 50]
   two = [10, 70, 50, 20, 90]
   three = [10, 80, 40, 20, 90]
   four = [50, 30, 20, 40, 60]
   a = [one, two, three, four]
   find(a)
 
def find(a):
    i = 0
    value = a[0][0]
    while(i < len(a)):
        x = 0
        while(x < len(a[i])):
            if(a[i][x] > value):
                value = a[i][x]            
            x += 1
        i += 1
    i = 0
    while(i < len(a)):
        x = 0
        while(x < len(a[i])):
           if( value == a[i][x]):
               print("Indices is"," [",i,"][",x,"] ",end = "")
           x += 1
        i += 1

setup()

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

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