使用数组x输出10个1-100之间的随机整数(包括1和100),下列命令中正确的是:( )
A: Dim x(9) As Integer For i = 1 To UBound(x) x(i) = Int(Rnd() * 100 + 1) Print x(i); Next
B: Dim x(9) As Integer For i = 0 To UBound(x) x(i) = Rnd(10) Print x(i); Next
C: Dim x(9) As Integer For i = 0 To UBound(x) x(i) = Int(Rnd() * 100 ) Print x(i); Next
D: Dim x(9) As Integer For i = 0 To UBound(x) x(i) = Int(Rnd() * 100 + 1) Print x(i); Next
A: Dim x(9) As Integer For i = 1 To UBound(x) x(i) = Int(Rnd() * 100 + 1) Print x(i); Next
B: Dim x(9) As Integer For i = 0 To UBound(x) x(i) = Rnd(10) Print x(i); Next
C: Dim x(9) As Integer For i = 0 To UBound(x) x(i) = Int(Rnd() * 100 ) Print x(i); Next
D: Dim x(9) As Integer For i = 0 To UBound(x) x(i) = Int(Rnd() * 100 + 1) Print x(i); Next
举一反三
- 运行下面的程序,第二行显示结果是___________。 Private Sub Form_Click() Dim A As Integer Dim i As Integer A = 5 For i = 1 To 9 Call sub1(i, A) Print i, A Next i End Sub Private Sub sub1(x As Integer, y As Integer) Static N As Integer Dim I As Integer For I = 3 To 1 Step -1 N = N + x x = x + 2 Next I y = y + N End Sub
- 下列程序运行时输出的结果是 Option Base 1 Private Sub Form_Click() Dim x (10)As Integer,y(5)As Integer For i=1 to 10 x(i)=10-i+1 Next For i=1 to 5 y(i)=x(2*i-1)+x(2*i) Next For i=1 to 5 Print y(i) Next End Sub A.3 7 11 45 19 B.19 15 11 7 3 C.1 3 5 7 9 D.不确定的值
- 1.以下程序的功能是:生成 20 个 200 到 300 之间的随机整数,输出其中能被 5 整除的数并求出它们的和。 Private Sub Command1_C1ick() Dim s As Integer Dim x As Integer, i As Integer s = 【1】 Randomize For i = 1 To 20 x = Int(【2】 * 101 + 200) If x 【3】 5 = 0 Then Print x s = s + x End If Next i Print "Sum ="; s End Sub
- 下面程序的功能是统计字符串中“i”的个数,请填空。 Sub COU( ) Dim n As Integer a$ = "Beijing University of Technology" n = Len(a$ ) For i = 1 To n b$ =Mid$(a$,i, 1) If 【11】 Then x=x + 1 Next Print "x ="; x End Sub
- 下列程序段的执行结果为; Dim X(3,5) For I=1 To 3 For J=1 To 5 X(I,J)=X(I-1,J-1)+I+J Next J Next I Print X(3,4) A: 12 B: 10 C: 18 D: 15