vb编写:建立并输出一个n*n的矩阵,该矩阵的主次对角线元素是1,其余元素均为0

2024-11-20 06:35:39
推荐回答(1个)
回答1:

n = 40 ‘矩阵大小
Dim x() As Long
ReDim x(n, n)
For a = 1 To n
x(a, a) = 1
x(a, n - (a - 1)) = 1
Next
For a = 1 To n
For b = 1 To n
Print x(a, b);
Next
Print "" Next
好了测试无错!