Matrixes elements pairing and printing examples with Small Basic
The video demonstrate the matrix's elements pairing and printing between two matrix.
For instance: there are 2 matrixes, matrixx and matrixy, each matrix contain elements:
matrixx = ["a","b","c"]
matrixy = ["z","y","x"]
The result of pairing each matrix elements would be:
a,z
a,y
a,x
b,z
b,y
b,x
c,z
c,y
c,x
You can see that total number of results or total number of paired elements (in our case) is 9. This is come from A x B. A is total number of matrix A's elements and B is total number of matrix B's elements. For example in this case, A = 3 and B = 3, then total number of paired elements is 3 x 3 = 9.
The results are printed out to the window of textwindow of the Small Basic.
The source code:
matriksx[1] = "a"
matriksx[2] = "b"
matriksx[3] = "c"
matriksx[4] = "d"
matriksy[1] = "z"
matriksy[2] = "y"
matriksy[3] = "x"
matriksy[4] = "w"
matriksy[5] = "v"
A = Array.GetItemCount(matriksx)
B = Array.GetItemCount(matriksy)
n = 1
For i = 1 To A
For j = 1 To B
TextWindow.WriteLine(n + ". " + matriksx[i]+","+matriksy[j])
n = n + 1
EndFor
n = n + 1
EndFor
TextWindow.WriteLine("Total pair :" + n)
Conclusion:
Notice:
1. The program still contain important error. The program still error in counting the total number of pairs or n.