def setup(): row1=[1,2,3] row2=[4,5,4] row3=[5,9,10] matrix1=[row1,row2,row3] arow1=[4,2,5] arow2=[1,1,2] arow3=[2,1,3] matrix2=[arow1,arow2,arow3] display_2D(multiply_matrix(matrix1,matrix2)) def multiply_matrix(aa,bb): i=0 matrix=[] while i<len(aa): col=0 matrix.append([]) while col<len(bb[0]): row=0 temp=0 while row<len(bb): temp+=aa[i][row]*bb[row][col] row+=1 matrix[i].append(temp) col+=1 i+=1 return matrix # =========== Display function =========== def display_2D(aa): i=0 while i<len(aa): display_1D(aa[i]) print() i+=1 def display_1D(a): i=0 while i<len(a): print(a[i],end=' ') i+=1 setup()
วันอังคารที่ 20 ตุลาคม พ.ศ. 2558
Lab06 : Multiply Matirx
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
commit เพิ่มเติม : เพื่ม userstory, bookmark
>> add userstory ทำการเพิ่ม userstory ใน functional tests >> add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...
-
1 2 3 4 5 6 7 8 9 def setup (): print (d2b( 8 )) def d2b (num): x = "" while num > 0 : x = str ( int (n...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 def test_layout_and_styling ( self ): # Edith goes to the home page self . brow...
-
การใช้ template inheritence คือการสืบทอดเทมเพลต เพื่อให้ไม่ต้องเขียนโค้ดหน้าเว็บๆซ้ำๆ เราจะมีหน้าหลักอันเดียว (base.html or parent) ภายในนั...
ไม่มีความคิดเห็น:
แสดงความคิดเห็น