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

Display the matrix

def setup():
   rowone = [1, 2, 3]
   rowtwo = [4, 5, 6]
   rowthree = [7, 8, 9]
   maxtrixone = [rowone, rowtwo, rowthree]
   rowfour = [10, 11, 12]
   rowfive = [13, 14, 15]
   rowsix = [16, 17, 18]
   maxtrixtwo = [rowfour, rowfive, rowsix]
   display(maxtrixone)
   print()
   display(maxtrixtwo)
 
def display(maxtrixone):
   i = 0
   while(i < len(maxtrixone)):
      j = 0
      print("|", end = "")
      while(j < len(maxtrixone[i])):
         print("",maxtrixone[i][j],"",end = "")
         j = j + 1
      print("|")
      i = i + 1
   
setup()

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

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