随即生成一个5*5的整数矩阵,该矩阵的副对角线上方元素是两位偶数,下方元素是奇数~怎么做啊~~
1个回答
展开全部
Dim A(5, 5) As Integer, i As Integer, j As Integer, s As String For i = 1 To 5 For j = 1 To 5 Randomize '加上这句,用于修改生成随机数的种子,否则总是生成相同的数" If j <= 5 - i Then A(i, j) = 2 * Int(Rnd * 45 + 5) Else A(i, j) = 2 * Int(Rnd * 45 + 5) + 1 End If Next j Next i For i = 1 To 5 For j = 1 To 5 s = s & Str(A(i, j)) Next j s = s & Chr(13) & Chr(10) Next i Text1.Text = s
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询