程序改错--答案版 下载本文

程序改错--答案版

程序改错

12592 '题目:编程求一个十进制整数n的各位数字之和,设n为小于或等于5位的数。 '------------------------------------------------ Option Explicit Private Form_Click()

'**********ERROR**********

Ch = Mid(N, i, 1)

'**********ERROR**********

Sub Sum Val(Ch) = Dim N As Integer, Next i

Sum As Integer, S1 As Print \该整数的String, S2 As String Ch As String Sum = 0

N = InputBox(\输入整数n\ S1 = Str(N) S1 = Trim(S1)

各位数之和是:\答案:Ch=Mid(S1 , i , 1) Sum = Sum + Val(Ch) 12610'题目:程序功能根据输入的学习成绩,

Dim i As Integer, End Sub

For i = 1 To 分别显示优秀(90分以Len(S1) 上), 良好(75分以上),

及格(60分以上)不及格2

程序改错

四个等级.

'------------------------------------------------ Option Explicit Private Form_Click() Cls

Dim i As Integer i = InputBox(\请输入学习成绩\Select Case i '**********ERROR********** 100 MsgBox \成绩

Case 75 To 89 Print \良好\

Case 60 To 74 Sub Print \

及格\

'**********ERROR********** Case MsgBox \不及格\End Select

答案:Case 100 < x or x < 0 Case 0 < i < End Sub

应该在0--100之间\ Case 90 to 100 '**********ERROR* Case Else ********* Case 90 Print \优秀\

12616.题目:求s=1!+3!+5!+7!,阶乘的计算用Function过程fact实现. 3