版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上【程序改錯(cuò)】題目:該程序?qū)崿F(xiàn)將輸入的 0 - 255 之間的正整數(shù)轉(zhuǎn)換成二進(jìn)制數(shù)Option ExplicitPrivate Sub Form_Click() Const n = 8 Dim a(n) As Integer, s As String, m As Integer, x As Integer x = Val(InputBox("請(qǐng)輸入一個(gè) 0 - 255 之間的正整數(shù):") Print x For m = 1 To n a(m) = x Mod 2 x = x / 2 Next m s = " " For m = n
2、 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分) 題號(hào):463'【程序改錯(cuò)】'題目:以下程序功能是輸入三個(gè)數(shù),由大到小排序。Option ExplicitDim A As IntegerDim B As IntegerDim C As IntegerPrivate Sub Form_Click() Dim nTemp As Integer A = Val(Inpu
3、tBox("Please input first integer", "輸入正整數(shù)") B = Val(InputBox("Please input second integer", "輸入正整數(shù)") C = Val(InputBox("Please input third integer", "輸入正整數(shù)") If A <= C Then nTemp = A A = B B = nTemp End If If B <= C Then nTemp = A A =
4、C C = nTemp End If If A <= B Then nTemp = B B = C C = nTemp End If Print "The integers in order is" A; B; CEnd 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分) 題號(hào):127'【程序改錯(cuò)】'題目:下面
5、程序可輸出如下圖形:' *' *' *' *' *'-Option ExplicitPrivate Sub Form_Click()Dim m As Integer, n As Integer, s As String, i As Integer, j As Integern = 4m = 1s = "*"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 - 1Next iEnd Su
6、b答案:=(答案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分) 題號(hào):469'【程序改錯(cuò)】'題目:已知一個(gè)函數(shù)f(x)=1000*sin(x),利用繪圖方法' 在圖片框中顯示其圖形。結(jié)果如圖1Option ExplicitPrivate Const pi = 3.14159Private Sub Command1_Click() Dim x As Integer Picture1.Scale (-p
7、i, -1200)-(pi, 1200) For x = -pi To pi Step pi Picture1.PSet (x, 1000 * pi * Sin(x), vbRed Next xEnd 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分) 題號(hào):497'【程序改錯(cuò)】'題目:編程求
8、一個(gè)十進(jìn)制整數(shù)n的各位數(shù)字之和,設(shè)n為小于或等于5位的數(shù)。Option ExplicitPrivate 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("輸入整數(shù)n") S1 = Str(N) S1 = RTrim(S1) For i = 1 To Len(S1) Ch = Mid(N, i, 1) Sum = Val(Ch) Next i Print "
9、該整數(shù)的各位數(shù)之和是:" 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分) 題號(hào):454'【程序改錯(cuò)】'題目:本程序的功能是隨機(jī)產(chǎn)生的10個(gè)兩位正整數(shù),并進(jìn)行遞減排序。Option ExplicitPrivate Sub CreateRND() Dim Temp As Integer Dim I As Integer Dim N As Integer D
10、im X(10) As Integer Dim J As Integer N = 10 Print "數(shù)據(jù):" 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 PrintEnd SubPrivate
11、 Sub Command1_Click() CreateRNDEnd 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分) 題號(hào):130'【程序改錯(cuò)】'題目:以下程序段用于計(jì)算5的N次方。Option ExplicitPriva
12、te Sub Form_Click() Dim n As Integer, k As Integer, s As Long n = InputBox(" Input n ") k = 0 s = 0 Do While k <= n s = s * 5 k = k + 1 Next Print "5的" "n次方是" sEnd Sub答案:=(答案1)=k=1=(答案2)=s=1=(答案3)=Loop第11題 (1.0分) 題號(hào):452'【程序改錯(cuò)】'題目:用自定義函數(shù)的方法求sum(x),求當(dāng)-1x1時(shí),'
13、; sum(x)=x/2!+x2/3!+x3/4!+xn/(n+1)!,' 當(dāng)x1或x-1時(shí),函數(shù)值為0。當(dāng)n=0時(shí),輸入數(shù)' 據(jù)錯(cuò)誤。X、N都是由用戶輸入。Option ExplicitPrivate Sub Command1_Click() Dim s As Single Dim n As Integer, x As Single, k As Integer n = Val(InputBox("Please input a integer value:") x = Val(InputBox("Please input a single valu
14、e:") If n <= 0 Then k = MsgBox("數(shù)據(jù)輸入錯(cuò)誤!", vbRetryCancel + vbExclamation, "數(shù)據(jù)輸入") Exit Sub End If s = Sum(x, n) Print sEnd SubFunction Sum(x As Single, n As Integer) Dim i As Integer, ss As Long ss = 1 Sum = 0 If x > 1 Or x < -1 Then Exit Do Else For i = 2 To n ss =
15、ss * i Sum = x (i - 1) / ss Next i End IfEnd Function答案:=(答案1)=exit Function=(答案2)=For i = 2 To n + 1=或=For i = 2 To 1+n=(答案3)=sum = sum + x (i - 1) / ss第14題 (1.0分) 題號(hào):136'【程序改錯(cuò)】'題目:程序功能為打印下列圖形:' *' *' *' *' *'-Option ExplicitPrivate Sub Form_Click()ClsDim i As Intege
16、rDim j As IntegerFor i = 1 To 7 For j = 1 To 5 Print "*" LoopPrintNext iEnd Sub答案:=(答案1)=For i = 1 To 5=(答案2)=For j = 1 To i=(答案3)=Next j=或=Next第16題 (1.0分) 題號(hào):461'【程序改錯(cuò)】'題目:產(chǎn)生30個(gè)小于100的成績隨機(jī)數(shù),并統(tǒng)計(jì)出優(yōu)、良' 、中等、及格、不及格數(shù)的個(gè)數(shù),并計(jì)算出成績屬' 于優(yōu)秀段的成績平均分。Option ExplicitPrivate Sub Form_Click()
17、Dim k%, a%, bjg%, jg%, zd%, lh%, yx As Integer Dim pjf As Integer Randomize pjf = 0 For k = 1 To 30 a = Int(Rnd() Select Case a Case 0 To 59 bjg = bjg + 1 '不及格 Case 60 To 69 jg = jg + 1 '及格 Case 70 To 79 zd = zd + 1 '中等 Case 80 To 89 lh = lh + 1 '良好 Case 90 To 100 yx = yx + 1 '優(yōu)秀
18、 pjf = pjf + 1 End Select Next k If yx > 0 Then pjf = pjf / 30 Debug.Print "不及格" + Str$(bjg) + "人,及格" + Str$(jg) + "人,中等" + Str$(zd) + "人" Debug.Print "良好" + Str$(lh) + "優(yōu)秀" + Str$(yx) + "人" Debug.Print "優(yōu)秀分?jǐn)?shù)段成績平均分" &
19、amp; pjfEnd Sub答案:=(答案1)=a = Int( Rnd() * 100)=或=a = Int( Rnd * 100)=(答案2)=pjf = pjf + a=(答案3)=If yx > 0 Then pjf = pjf / yx第17題 (1.0分) 題號(hào):456'【程序改錯(cuò)】'題目:挑選單數(shù)并排序程序:程序啟動(dòng)后由計(jì)算機(jī)自動(dòng)產(chǎn)' 生20個(gè)屬于100,300之間的隨機(jī)整數(shù),單擊"顯' 示全體"按鈕時(shí),在Form1上顯示這20個(gè)隨機(jī)數(shù);' 單擊"顯示奇數(shù)"按鈕時(shí),在Form1上顯示其中的奇數(shù)
20、;' 單擊"排序"按鈕時(shí),在Form1上將這些奇數(shù)從小到大顯示。' 要求顯示格式為每行顯示5個(gè)數(shù)據(jù)。Option ExplicitPrivate a(20) As Integer, b(20) As IntegerPrivate k As IntegerPrivate Sub cmdodd_Click()Dim I As Integerk = 0For I = 1 To 20 If a(I) / 2 = Int(a(I) / 2) Then k = k + 1 b(k) = a(I) End IfNext IFor I = 1 To k Print b(I)
21、; If Int(I / 5) <> I / 5 Then PrintNext IPrintEnd SubPrivate Sub cmdAll_Click() Randomize Dim I As Integer For I = 1 To 20 a(I) = Int(Rnd() * 20 + 100) Print a(I), If Int(I / 5) = I / 5 Then Print Next I PrintEnd SubPrivate Sub cmdsort_Click() Dim I As Integer Dim J As Integer Dim Temp As Inte
22、ger For I = 1 To k - 1 For J = I To k If b(I) > b(J) Then Temp = b(I): b(I) = b(J): b(J) = Temp Next J Next I For I = 1 To k Print b(I); If Int(I / 5) = I / 5 Then Print Next IEnd Sub答案:=(答案1)=If a(I) / 2 <> Int(a(I) / 2) Then=或=If a(I) mod 2 <>0 Then=或=If 0<>a(I) mod 2 Then=或=I
23、f a(I) / 2 <> a(I) 2 Then=或=If int(a(I) / 2) <> a(I) / 2 Then=或=If 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 / 5= int(I / 5) Then Print=或=If I / 5= I 5 Then Print=或=If I 5= I/ 5 Then Print=(答案3)=a(I)
24、= Int(Rnd() * 200 + 100)第19題 (1.0分) 題號(hào):499'【程序改錯(cuò)】'題目:編程將一個(gè)數(shù)從已經(jīng)有序(設(shè)從小到大排序)的數(shù)組' 中刪除,使數(shù)組還繼續(xù)保持有序而且其余元素按照下' 標(biāo)連續(xù)存放。Option ExplicitPrivate Sub Form_Click() Dim A() As Integer, N As Integer, Flag As Integer Dim i As Integer, X As Integer, P As Integer Flag = 0 N = InputBox("輸入元素個(gè)數(shù)"
25、) Dim A(N) For i = 1 To N A(i) = InputBox("輸入數(shù)組的第" & i & "個(gè)元素") Next i Print "刪除某元素前的數(shù)組" For i = 1 To N Print A(i); Next iStart: X = InputBox("輸入要?jiǎng)h除的元素:") For i = 1 To N If X = A(i) Then P = i: Flag = 1 Next i If Flag = 0 Then MsgBox ("沒有此元素"
26、): GoTo Start For i = P To N - 1 A(i + 1) = A(i) Next i N = N + 1 Print "刪除元素后的數(shù)組:" For i = 1 To N Print A(i); Next iEnd Sub答案:=(答案1)=ReDim A(N)=(答案2)=A(i) = A(i + 1)=或=A(i) = A(1 + i)=(答案3)=N = N - 1第20題 (1.0分) 題號(hào):139'【程序改錯(cuò)】'題目:隨機(jī)產(chǎn)生并輸出100以內(nèi)大于50的20個(gè)整數(shù),輸' 出時(shí)每5個(gè)數(shù)一行。Option Explici
27、tPrivate Sub Form_Click()Randomize TimerDim i As Integer, ma As Integeri = 1Do Until i < 20 ma = Rnd() * 100 1 If ma > 50 Then Print ma; i = i + 1 If i 5 = 0 Then Print End IfEnd IfLoopEnd Sub答案:=(答案1)=i = 0=(答案2)=Do while i < 20=或=Do while 20 > i=或=Do while i <=19=或=Do while 19 >
28、=i=(答案3)=If i mod 5 = 0 Then第23題 (1.0分) 題號(hào):474'【程序改錯(cuò)】'題目:程序功能為求解一元二次方程的實(shí)根,請(qǐng)修正程序中錯(cuò)誤。Option ExplicitPrivate Sub Form_Load() Dim a!, b!, c!, root1#, root2#, work As Double a = Val(InputBox(" 請(qǐng)輸入系數(shù)a的值") b = Val(InputBox(" 請(qǐng)輸入系數(shù)b的值") c = Val(InputBox(" 請(qǐng)輸入系數(shù)c的值") wor
29、k = b * 2 - 4 * a * c If work >= 0 And a <> 0 Then root1 = (Sqr(work) / (2 * a) root2 = (Sqr(work) / (2 * a) Debug.Print "有二個(gè)實(shí)根" + Str$(root1) + "," + Str$(root2) Else Debug.Print "無實(shí)根!" End IfEnd Sub答案:=(答案1)=work = b 2 - 4 * a * c=或=work = b *b - 4 * a * c=(答
30、案2)=root1 = (-b + Sqr(work) / (2 * a)=或=root1 = ( Sqr(work) -b ) / (2 * a)=或=root1 = (-b + Sqr(work) / ( a*2)=或=root1 = ( Sqr(work) -b ) / ( a*2)=(答案3)=root2 = (-b - Sqr(work) / (2 * a)=或=root2 = (- Sqr(work) - b) / (2 * a)=或=root2 = (-b - Sqr(work) / ( a*2)=或=root2 = (- Sqr(work) - b) / (a*2)第28題 (
31、1.0分) 題號(hào):133'【程序改錯(cuò)】'題目:下面程序?qū)?0個(gè)整數(shù)從大到小排序Option ExplicitPrivate Sub Form_Click()Dim t%, m%, n%, w%Dim a(10) As IntegerFor m = 1 To 10 a(m) = Int(10 + Rnd() * 90) Print a(m); " "Next mPrintFor m = 1 To 9 t = m For n = 2 To 10 If a(t) > a(n) Then n = t Next n If t = m Then w = a(m)
32、a(m) = a(t) a(t) = w End IfNext mFor m = 1 To 10 Print a(m)Next mEnd Sub答案:=(答案1)=For n = m + 1 To 10=(答案2)=If a(t) <a(n) Then t = n=或=If a(n) >a(t) Then t = n=(答案3)=If t <> m Then=或=If not t = m Then=或=If not m = t Then第30題 (1.0分) 題號(hào):480'【程序改錯(cuò)】'題目:下面函數(shù)的功能是:求變量s(s=a+aa+aaa+aaaa+)
33、' 的值。其中,a是一個(gè)0-9的數(shù)字,總共累加a項(xiàng)。' 例如,當(dāng)a=3時(shí),s=3+33+333 (共累加3項(xiàng))。Option ExplicitPublic Function Calc(a As Integer) Dim s As Long Dim t As Long Dim i As Integer s = a t = 1 For i = 2 To a t = t + a s = s + t Next i Calc = s Print sEnd FunctionPrivate Sub Command1_Click() Dim i As Integer i = InputBox(
34、"請(qǐng)輸入數(shù)字(0-9):") Calc call iEnd Sub答案:=(答案1)=t = a=(答案2)=t = t * 10 + a=或=t = t * 10 + a=或=t = t * 10 + a=(答案3)=Calc i=或=Call Calc(i)=或=Calc (i)第31題 (1.0分) 題號(hào):489'-'【程序改錯(cuò)】'-'題目:給定三角形的三條邊,計(jì)算三角形的面積。要求' 程序首先判斷給定的三條邊能否構(gòu)成三角形。'-Option ExplicitPrivate Sub Form_Click() Dim a
35、As Single, b As Single, c As Single Dim s As Single, t As Singlestart: a = InputBox("輸入1邊長:") b = InputBox("輸入2邊長:") c = InputBox("輸入3邊長:") If a + b < c Or b + c < a Then MsgBox ("不能構(gòu)成三角形,請(qǐng)重新輸入個(gè)邊") GoTo start End If t = (a + b) / 2 s = Sqr(t - a) * (t -
36、b) * (t - c) Print "該三角形的面積:" sEnd Sub答案:=(答案1)=If a + b < c Or b + c < a Or a + c < b Then=(答案2)=t = (a + b + c) / 2=或=t = (a + b + c ) / 2=(答案3)=s = Sqr(t * (t - a) * (t - b) * (t - c)=或=s = Sqr( t * (t - a) * (t - b) * (t - c) )第32題 (1.0分) 題號(hào):475'-'【程序改錯(cuò)】'-'題目:本
37、程序求3100之間的所有素?cái)?shù)(質(zhì)數(shù))并統(tǒng)計(jì)個(gè)數(shù);' 同時(shí)將這些素?cái)?shù)從小到大依次寫入順序文件c:dataout.txt;' 素?cái)?shù)的個(gè)數(shù)顯示在窗體Form1上。'-Option ExplicitPrivate Sub Command1_Click() Dim Count As Integer, Flag As Boolean Dim t1 As Integer, t2 As Integer Open "dataout.txt" For Input As #1 Count = 0 For t1 = 3 To 100 Flag = True For t2 =
38、 2 To Int(Sqr(t1) If t1 Mod t2 = 0 Then Flag = False Next t2 If Flag = False Then Count = Count + 1 Write #1, t2 End If Next t1 Form1.Print "素?cái)?shù)個(gè)數(shù)" Count Close #1End Sub答案:=(答案1)=Open "dataout.txt" For Output As #1=或=Open "dataout.txt" For Output As 1=(答案2)=If Flag Then=
39、或=If Flag=true Then=(答案3)=Write #1, t1=或=Write 1, t1第33題 (1.0分) 題號(hào):137'-'【程序改錯(cuò)】'-'題目:求s=72+102+132+832的值。'-Option ExplicitPrivate Sub Form_Click()ClsDim s As LongDim i As Integers = 1For i = 7 To 832s = s + iloop 30Print sEnd Sub答案:=(答案1)=s =0=(答案2)=For i = 7 To 832 step 30=(答案3)
40、=Next i=或=Next第35題 (1.0分) 題號(hào):131'-'【程序改錯(cuò)】'-'題目:下面程序用于將十個(gè)數(shù)字從小到大排序'-Option ExplicitOption Base 1Private Sub Form_Click()ClsDim a(10) As IntegerDim i As Integer, j As Integer, temp As IntegerFor i = 0 To 10If i Mod 2 = 0 Then a(i) = i Else a(i) = -iPrint a(i);NextPrintFor i = 1 To 1
41、0For j = 1 To 10 - iIf a(j) < a(j + 1) Thentemp = a(j): a(j) = a(j + 1): a(j + 1) = tempEnd IfNext i, jFor i = 1 To 10Print a(i);NextEnd Sub答案:=(答案1)=For i = 1 To 10=(答案2)=If a(j) > a( j + 1 ) Then=或=If a( j + 1 ) <a (j) Then=(答案3)=Next j, i第40題 (1.0分) 題號(hào):141'-'【程序改錯(cuò)】'-'題目:輸
42、出40以內(nèi)能夠被3整除的數(shù),要求輸出結(jié)果為5' 個(gè)數(shù)一行。'-Option ExplicitPrivate Sub Form_Click()ClsDim x As IntegerDim i As Integeri = 1For x = 1 To 40If (x / 3) = (x 3) Then Print x i = i + 1End If If i Mod 3 = 0 Then PrintEnd IfNext xEnd Sub答案:=(答案1)=i = 0=(答案2)=Print x;=(答案3)=if i mod 5=0 then第42題 (1.0分) 題號(hào):117'-'【程序改錯(cuò)】'-'題目:下面的程序段用于實(shí)現(xiàn)以下功能:建立一順序文'件,存放10名同學(xué)的學(xué)號(hào)和三門功課成績,顯示'該文件內(nèi)所有記錄, 并同時(shí)顯示其總分和平均分'-Option ExplicitPrivate Sub Form_Click()Dim no%, c1%, c2%, c3%, i As IntegerOpen "c:2.txt" For Input As #1For i = 1 To 10 no = InputBox("請(qǐng)輸入學(xué)號(hào)") c1 = InputBox(&
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 研學(xué)課程設(shè)計(jì)剪紙
- 水控課程設(shè)計(jì)致謝模板
- 2024年吉林省安全員-B證考試題庫附答案
- 油品儲(chǔ)存與裝卸課程設(shè)計(jì)
- 研學(xué)課程設(shè)計(jì)措施和方法
- 電池課程設(shè)計(jì)目錄
- 2024江西省安全員《B證》考試題庫
- 2025四川省建筑安全員《B證》考試題庫
- 2025天津市安全員-C證(專職安全員)考試題庫
- 渦輪本體課程設(shè)計(jì)工序卡
- 齊魯名家 談方論藥智慧樹知到期末考試答案2024年
- 2024年華電甘肅大基地煤電分公司招聘筆試參考題庫含答案解析
- 2022年度設(shè)備部安全生產(chǎn)工作計(jì)劃5篇
- GB∕T 39757-2021 建筑施工機(jī)械與設(shè)備 混凝土泵和泵車安全使用規(guī)程
- 英國學(xué)派多元主義與社會(huì)連帶主義論爭
- 電梯公司安全生產(chǎn)管理制度匯編.doc
- 兒童保健檔案表.doc
- 閥門檢測報(bào)告
- 新產(chǎn)品開發(fā)流程表
- 保命未來經(jīng)0001
- 北京市養(yǎng)老機(jī)構(gòu)公建民營實(shí)施辦法(20210220135609)
評(píng)論
0/150
提交評(píng)論