高校等考试题天天练二级VB]10月26日
分类: 计算机
时间: 2022-09-27 22:25:54
作者: 全国等级考试资料网
知识点:程序填空(三)
以下程序段用于输入整数n,在窗体上显示如下图所示具有n行的杨辉三角。
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
…
Dim s(20, 20) As Integer
Dim i%, j%, k%, n%
n = InputBox("输入一个正整数:")
For i = 1 To n
s(i, 1) = 1
(4) =1
Next i
For i = 3 To n
For j = 2 To i - 1
s(i, j) = s(i - 1, j - 1) + (5)
Next j
Next i
For i = 1 To n
For j = 1 To i
Print s(i, j);
Next j
(6)
Next i
以下程序段用于输入整数n,在窗体上显示如下图所示具有n行的杨辉三角。
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
…
Dim s(20, 20) As Integer
Dim i%, j%, k%, n%
n = InputBox("输入一个正整数:")
For i = 1 To n
s(i, 1) = 1
(4) =1
Next i
For i = 3 To n
For j = 2 To i - 1
s(i, j) = s(i - 1, j - 1) + (5)
Next j
Next i
For i = 1 To n
For j = 1 To i
Print s(i, j);
Next j
(6)
Next i