Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Identity-matrix/VBScript/identity-matrix-1.vb
Normal file
29
Task/Identity-matrix/VBScript/identity-matrix-1.vb
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
build_matrix(7)
|
||||
|
||||
Sub build_matrix(n)
|
||||
Dim matrix()
|
||||
ReDim matrix(n-1,n-1)
|
||||
i = 0
|
||||
'populate the matrix
|
||||
For row = 0 To n-1
|
||||
For col = 0 To n-1
|
||||
If col = i Then
|
||||
matrix(row,col) = 1
|
||||
Else
|
||||
matrix(row,col) = 0
|
||||
End If
|
||||
Next
|
||||
i = i + 1
|
||||
Next
|
||||
'display the matrix
|
||||
For row = 0 To n-1
|
||||
For col = 0 To n-1
|
||||
If col < n-1 Then
|
||||
WScript.StdOut.Write matrix(row,col) & " "
|
||||
Else
|
||||
WScript.StdOut.Write matrix(row,col)
|
||||
End If
|
||||
Next
|
||||
WScript.StdOut.WriteLine
|
||||
Next
|
||||
End Sub
|
||||
15
Task/Identity-matrix/VBScript/identity-matrix-2.vb
Normal file
15
Task/Identity-matrix/VBScript/identity-matrix-2.vb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
n = 8
|
||||
|
||||
arr = Identity(n)
|
||||
|
||||
for i = 0 to n-1
|
||||
for j = 0 to n-1
|
||||
wscript.stdout.Write arr(i,j) & " "
|
||||
next
|
||||
wscript.stdout.writeline
|
||||
next
|
||||
|
||||
Function Identity (size)
|
||||
Execute Replace("dim a(#,#):for i=0 to #:for j=0 to #:a(i,j)=0:next:a(i,i)=1:next","#",size-1)
|
||||
Identity = a
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue