1、【程序改错】题目:该程序实现将输入的 0 - 255 之间的正整数转换成二进制数Option ExplicitPrivate Sub Form_Click()Const n = 8Dim a(n) As Integer, s As String, m As Integer, x As Integerx = Val(InputBox(“请输入一个 0 - 255 之间的正整数:“)Print xFor m = 1 To na(m) = x Mod 2x = x / 2Next ms = “ “For m = n To 0 Step -1s = Str(a(m)Next mPrint sEnd S
2、ub答案:=(答案 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 ExplicitDim A As IntegerDim B As IntegerDim C As IntegerPrivate Sub Form_Click()Dim nTemp As IntegerA = Val(InputBox(“Please input first integer“, “输入正整数“)B = Val(In
3、putBox(“Please input second integer“, “输入正整数“)C = Val(InputBox(“Please input third integer“, “输入正整数“)If A = A Then=(答案 2)=If A = A Then=(答案 3)=If B = B Then第 4 题 (1.0 分) 题号:127【程序改错】题目:下面程序可输出如下图形: * * * * *-Option ExplicitPrivate Sub Form_Click()Dim m As Integer, n As Integer, s As String, i As Int
4、eger, j As Integern = 4m = 1s = “*“For i = 5 To 1 Step -1Print Spc(n)For j = 1 To 2 * m - 1Print s;Next jPrintn = n + 1m = m - 1Next iEnd 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
5、(x),利用绘图方法 在图片框中显示其图形。结果如图 1Option ExplicitPrivate Const pi = 3.14159Private Sub Command1_Click()Dim x As IntegerPicture1.Scale (-pi, -1200)-(pi, 1200)For x = -pi To pi Step piPicture1.PSet (x, 1000 * pi * Sin(x), vbRedNext xEnd Sub答案:=(答案 1)=Dim x As Single=或=Dim x!=(答案 2)=For x = -pi To pi Step pi
6、 / 180=(答案 3)=Picture1.PSet (x, 1000 * Sin(x), vbRed=或=Picture1.PSet (x, Sin(x)*1000), vbRed第 6 题 (1.0 分) 题号:497【程序改错】题目:编程求一个十进制整数 n 的各位数字之和,设 n 为小于或等于 5 位的数。Option ExplicitPrivate Sub Form_Click()Dim N As Integer, Sum As Integer, S1 As String, S2 As StringDim i As Integer, Ch As StringSum = 0N = I
7、nputBox(“输入整数 n“)S1 = Str(N)S1 = RTrim(S1)For i = 1 To Len(S1)Ch = Mid(N, i, 1)Sum = Val(Ch)Next iPrint “该整数的各位数之和是:“; SumEnd 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 个两位正整数,并进行
8、递减排序。Option ExplicitPrivate Sub CreateRND()Dim Temp As IntegerDim I As IntegerDim N As IntegerDim X(10) As IntegerDim J As IntegerN = 10Print “数据:“For I = 1 To NX(I) = Int(Rnd() * 90)Print X(I);Next IPrintPrint “排序:“For I = 0 To N - 1For J = I + 1 To NIf X(I) X(J) ThenTemp = X(I)X(J) = X(I)X(I) = Te
9、mpEnd IfNext JPrint X(I);Next IPrintEnd SubPrivate Sub Command1_Click()CreateRNDEnd Sub答案:=(答案 1)=X(I) = Int(10 + Rnd() * 90)=或=X(I) = Int(10 + Rnd() * 90)=(答案 2)=If X(I) X(I) Then=或=If X(J) = X(I) Then=(答案 3)=temp = X(J)第 9 题 (1.0 分) 题号:130【程序改错】题目:以下程序段用于计算 5 的 N 次方。Option ExplicitPrivate Sub Form
10、_Click()Dim n As Integer, k As Integer, s As Longn = InputBox(“ Input n “)k = 0s = 0Do While k 1 Or x 0 Then pjf = pjf / 30Debug.Print “不及格“ + Str$(bjg) + “人,及格“ + Str$(jg) + “人,中等“ + Str$(zd) + “人“;Debug.Print “良好“ + Str$(lh) + “优秀“ + Str$(yx) + “人“Debug.Print “优秀分数段成绩平均分“ If Int(I / 5) b(J) Then T
11、emp = b(I): b(I) = b(J): b(J) = TempNext JNext IFor I = 1 To kPrint b(I);If Int(I / 5) = I / 5 Then PrintNext IEnd Sub答案:=(答案 1)=If a(I) / 2 0 Then=或=If 0 a(I) 2 Then=或=If int(a(I) / 2) a(I)/2 Then=(答案 2)=If Int(I / 5) = I / 5 Then Print=或=If I mod 5 = 0 Then Print=或=If 0 = I mod 5 Then Print=或=If I
12、 / 5= int(I / 5) Then Print=或=If I / 5= I 5 Then Print=或=If I 5= I/ 5 Then Print=(答案 3)=a(I) = Int(Rnd() * 200 + 100)第 19 题 (1.0 分) 题号:499【程序改错】题目:编程将一个数从已经有序(设从小到大排序)的数组 中删除,使数组还继续保持有序而且其余元素按照下 标连续存放。Option ExplicitPrivate Sub Form_Click()Dim A() As Integer, N As Integer, Flag As IntegerDim i As In
13、teger, X As Integer, P As IntegerFlag = 0N = InputBox(“输入元素个数“)Dim A(N)For i = 1 To NA(i) = InputBox(“输入数组的第“ Next iStart:X = InputBox(“输入要删除的元素:“)For i = 1 To NIf X = A(i) Then P = i: Flag = 1Next iIf Flag = 0 Then MsgBox (“没有此元素“): GoTo StartFor i = P To N - 1A(i + 1) = A(i)Next iN = N + 1Print “删除元素后的数组:“For i = 1 To NPrint A(i);Next iEnd Sub答案:=(答案 1)=ReDim A(N)=(答案 2)=A(i) = A(i + 1)=或=A(i) = A(1 + i)
Copyright © 2018-2021 Wenke99.com All rights reserved
工信部备案号:浙ICP备20026746号-2
公安局备案号:浙公网安备33038302330469号
本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。