【程序改错】
题目:该程序实现将输入的 0 - 255 之间的正整数转换成二进制数 Option Explicit
Private Sub Form_Click() Const n = 8
Dim a(n) As Integer, s As String, m As Integer, x As Integer x = Val(InputBox(\请输入一个 0 - 255 之间的正整数:\ Print x
For m = 1 To n a(m) = x Mod 2 x = x / 2 Next m s = \
For m = n To 0 Step -1 s = Str(a(m)) Next m Print s End Sub 答案:
=======(答案1)======= For m = 0 To n
=======(答案2)======= x= x \\ 2
=========或========= x= int(x/2)
=======(答案3)======= s = s + Str(a(m))
第3题 (1.0分) 题号:463 '【程序改错】
'题目:以下程序功能是输入三个数,由大到小排序。 Option Explicit Dim A As Integer Dim B As Integer Dim C As Integer
Private Sub Form_Click() Dim nTemp As Integer
A = Val(InputBox(\输入正整数\ B = Val(InputBox(\输入正整数\ C = Val(InputBox(\输入正整数\ If A <= C Then nTemp = A A = B B = nTemp End If
If B <= C Then nTemp = A A = C C = nTemp
End If
If A <= B Then nTemp = B B = C C = nTemp End If
Print \End Sub 答案:
=======(答案1)======= If A <= B Then
=========或========= If B >= A Then
=======(答案2)======= If A <= C Then
=========或========= If C >= A Then
=======(答案3)======= If B <= C Then
=========或========= If C >= B Then
第4题 (1.0分) 题号:127 '【程序改错】
'题目:下面程序可输出如下图形: ' * ' *** ' ***** ' ******* ' *********
'------------------------------------------------ Option Explicit
Private Sub Form_Click()
Dim m As Integer, n As Integer, s As String, i As Integer, j As Integer n = 4 m = 1 s = \
For i = 5 To 1 Step -1
Print Spc(n)
For j = 1 To 2 * m - 1 Print s; Next j Print
n = n + 1
m = m - 1
Next i End Sub 答案:
=======(答案1)======= Print Spc(n);
=========或========= Print Spc(i);
=========或========= ? Spc(n);
=========或========= ? Spc(i);
=======(答案2)======= n = n - 1
=========或========= n = - 1+n
=======(答案3)======= m = m + 1
第5题 (1.0分) 题号:469 '【程序改错】
'题目:已知一个函数f(x)=1000*sin(x),利用绘图方法 ' 在图片框中显示其图形。结果如图1 Option Explicit
Private Const pi = 3.14159 Private Sub Command1_Click()
Dim x As Integer
Picture1.Scale (-pi, -1200)-(pi, 1200)
For x = -pi To pi Step pi
Picture1.PSet (x, 1000 * pi * Sin(x)), vbRed Next x End Sub 答案:
=======(答案1)======= Dim x As Single
=========或========= Dim x!
=======(答案2)=======
For x = -pi To pi Step pi / 180 =======(答案3)=======
Picture1.PSet (x, 1000 * Sin(x)), vbRed =========或=========
Picture1.PSet (x, Sin(x)*1000), vbRed 第6题 (1.0分) 题号:497 '【程序改错】
'题目:编程求一个十进制整数n的各位数字之和,设n为小于或等于5位的数。 Option Explicit
Private Sub Form_Click()
Dim N As Integer, Sum As Integer, S1 As String, S2 As String Dim i As Integer, Ch As String Sum = 0
N = InputBox(\输入整数n\ S1 = Str(N)
S1 = RTrim(S1)
For i = 1 To Len(S1)
Ch = Mid(N, i, 1)
Sum = Val(Ch) Next i
Print \该整数的各位数之和是:\End Sub 答案:
=======(答案1)======= S1 = Trim(S1)
=========或========= S1 = lTrim(S1)
=======(答案2)======= Ch = Mid(S1, i, 1) =======(答案3)======= Sum = Sum + Val(Ch) =========或========= Sum = Sum + Val(Ch)
第7题 (1.0分) 题号:454 '【程序改错】
'题目:本程序的功能是随机产生的10个两位正整数,并进行递减排序。 Option Explicit
Private Sub CreateRND() Dim Temp As Integer Dim I As Integer Dim N As Integer Dim X(10) As Integer Dim J As Integer N = 10
Print \数据:\ For I = 1 To N
X(I) = Int(Rnd() * 90) Print X(I); Next I Print
Print \排序:\ For I = 0 To N - 1 For J = I + 1 To N
If X(I) > X(J) Then
Temp = X(I) X(J) = X(I) X(I) = Temp End If Next J
Print X(I); Next I Print End Sub
Private Sub Command1_Click() CreateRND End Sub 答案:
=======(答案1)=======
X(I) = Int(10 + Rnd() * 90) =========或=========
X(I) = Int(10 + Rnd() * 90) =======(答案2)======= If X(I) < X(J) Then =========或========= If X(I) <= X(J) Then =========或========= If X(J) > X(I) Then =========或========= If X(J) >= X(I) Then =======(答案3)======= temp = X(J)
第9题 (1.0分) 题号:130 '【程序改错】
'题目:以下程序段用于计算5的N次方。 Option Explicit
Private Sub Form_Click()
Dim n As Integer, k As Integer, s As Long n = InputBox(\ k = 0 s = 0
Do While k <= n s = s * 5 k = k + 1 Next
Print \的\次方是\End Sub 答案:
=======(答案1)======= k=1
=======(答案2)======= s=1
=======(答案3)=======