程序设计题
1、题目:(事件)单击窗体(响应)用输入框输入一自然数,判断是\正数\、\负数或\零\,并根据输入的数用消息框显示\正数\、\负数”或\零\。
2、题目:(事件)单击窗体。(响应)求200~300之间既能被3整除又能被7整除的数。并求出所有数之和存入变量SUM中
3、题目:单击窗体。(响应)已知S=1+1/4+1/9+1/16+1/25+?+1/100,结果输出在窗体上。
4、题目:(事件)单击窗体。(响应)在窗体上打印数列2/1,3/2,5/3,8/5,13/8?的前10项,并求其和,将和保存在变量s中。
5、题目:(事件)双击窗体。(响应)把一元钞票换成一分、二分和五分的硬币每种至少有一枚),求出其所有的换法,把结果输出在窗体上。将所有的换法的数目存入变量N中
6、题目:单击窗体。)求1!+2!+3!+4!+5!并将结果输出到窗体上。结果存入变量S中 7、题目:(事件)单击窗体。(响应)生成一个一维数组(10个数组元素依此为: ' 15、23、72、43、96、23、3、65、88、17
写程序求出这个数组中的最大值、最小值和平均值,并输出在窗体上。将最大值,最小值,平均值分别存入变量Max,Min,Aver中
8、题目:(事件)单击窗体。(响应)在窗体上输出100~200之间的所有合数。求出所有数之和存入SUM中所谓合数是指自然数中能被1和本数整除以外,还能被其他数整除的数。
9、题目:(事件)单击窗体。(响应)求10~20之间所有素数的乘积并输出在窗体上。将结果存入变量L中。
10、题目:(事件)单击窗体。(响应)求1 - 1/2 + 1/3 - 1/4 + ?? + 1/99 - 1/100的值。将结果存入变量J中。 1题
n = InputBox(\输入一个自然数\If n > 0 Then
result = \正数\ElseIf n < 0 Then result = \负数\ElseIf n = 0 Then result = \零\End If
MsgBox \输入的数据\为:\2题
Dim i As Integer For i = 201 To 300
If ((i Mod 3) = 0) And ((i Mod 7) = 0) Then Print (CStr(i)) sum = sum + i End If Next
Print sum 3题
Dim i As Integer s = 0
For i = 1 To 10 s = s + 1 / (i ^ i) Next
Print (s) 4题 Dim i, j, k, m As Integer s = 0 :i = 2:j = 1 For k = 1 To 10 s = s + i / j m = j
Print (CStr(i)) & \ j = i
i = i + m Next 5题
Dim i, j, k As Integer For i = 1 To 100 For j = 1 To 50 For k = 1 To 20
If ((i + 2 * j + k * 5) = 100) Then Print (CStr(i)) Print (CStr(j)) Print (CStr(k))
n = n + 1 End If Next Next Next 6题
Dim i, j, k As Integer For i = 1 To 5 k = 1
For j = 1 To i k = k * j Next
s = s + k Next
Print (CStr(s)) 7题
Dim a(9) As Integer Dim i, s As Integer
a(0) = 15:a(1) = 23:a(2) = 72 a(3) = 43:a(4) = 96:a(5) = 23 a(6) = 3:a(7) = 65:a(8) = 88 a(9) = 17:max = a(0):min = a(0) s = 0
For i = 0 To 9
If a(i) > max Then max = a(i) End If
If a(i) < min Then min = a(i) End If s = s + a(i) Next
aver = Int(s / 10) Print (CStr(max)) Print (CStr(min)) Print (CStr(aver)) 8题
Dim i, j, s As Integer For i = 100 To 200
For j = 2 To Sqr(i)
If (i Mod j) = 0 Then Print (CStr(i)) sum = sum + i Exit For End If Next Next
Print sum 9题
Dim i%,j%,b As Boolean l = 1:b = False For i = 10 To 20 For j = 2 To i - 2
If i Mod j = 0 Then b = True End If Next
If b = False Then l = l * i End If b = False Next
Print Str(l)
10题
Dim i As Integer For i = 1 To 100
If i Mod 2 = 1 Then j = j + 1 / i
ElseIf i Mod 2 = 0 Then j = j - 1 / i End If Next
Print j
11、题目: (事件)单击窗体。(响应)如果一个数的真因子之和等于这个数本身,则称这样的数为“完全数”。例如,整数28的真因子为1、2、4、7、11,其和是28。因此28是一个完全数。请编写一个程序,求出500以内最大的完全数。并存入变量SUM中。使用for...next语句完成程序
12、题目:应用选择法对数组A按升序排列
13、题目:单击窗体。求一个数,它除3余2,除5余3,除7余2,请将满足上面条件的最小数保存到sum变量中。使用for...next语句完成程序。
14、题目:编写函数fun,函数的功能是:判断一个字符是字母字符、数字字符还是其他字符,并做相应的显示。字母字符显示字符串\字母\,数字字符显示字符串\数字\,其他字符显示字符串\其他\,要求使用IF语句来实现。
Private Function fun(n As String) As String '**********Program**********
'********** End ********** End Function
Private Sub Form_Load() Show
Print fun(\ Print fun(\ Print fun(\ NJIT_VB End Sub
Private Sub NJIT_VB() Dim i As Integer Dim l As Integer
Dim a(10) As String * 1 Dim fIn As Integer Dim fOut As Integer fIn = FreeFile
Open App.Path & \ fOut = FreeFile
Open App.Path & \ For i = 1 To 10
Line Input #fIn, a(i) Print #fOut, fun(a(i)) Next
Close #fIn Close #fOut End Sub 15、题目:编写函数fun,函数的功能是:根据一个百分制成绩mark(整数),显示对应五级制的评定。条件如下:
'mark大于等于90显示\优秀\
'mark小于90且大于等于80显示\良好\'mark小于80且大于等于70显示\中等\'mark小于70且大于等于60显示\及格\'mark小于60显示\不及格\'要求使用IF语句来实现。
Private Function fun(mark As Integer) As String '**********Program**********
'********** End ********** End Function
Private Sub Form_Load() Show
Print fun(90) NJIT_VB End Sub
Private Sub NJIT_VB() Dim i As Integer Dim s As String
Dim a(10) As Integer Dim fIn As Integer Dim fOut As Integer fIn = FreeFile
Open App.Path & \ fOut = FreeFile
Open App.Path & \ For i = 1 To 10
Line Input #fIn, s a(i) = Val(s)
Print #fOut, fun(a(i)) Next
Close #fIn Close #fOut End Sub
16、题目:编写函数fun,函数的功能是:当x的初值为10,每年增长率为千分之八,计算多少年以后x的值能达到y,并显示所需年数的值(变量名必须为n)。
'要求使用Do While ... Loop语句来实现。 Private Function fun(y As Single) As Long Dim x As Single, n As Long
'**********Program**********
'********** End **********
End Function
Private Sub Form_Load() Show
Print fun(15) NJIT_VB End Sub
Private Sub NJIT_VB() Dim i As Integer Dim a(10) As String Dim fIn As Integer Dim fOut As Integer fIn = FreeFile Open App.Path & \ fOut = FreeFile Open App.Path & \ For i = 1 To 10 Line Input #fIn, a(i)
Print #fOut, Trim(Str(fun(Val(a(i))))) Next
Close #fIn Close #fOut End Sub
17、题目:编写函数fun,函数的功能是:求从m到n的乘积并显示,'如:m为2,n为4时,显示\存储连乘的乘积的变量必须为Product'要求使用For语句来实现。
Private Function fun(m As Integer, n As Integer) As Long Dim Product As Double, t As Integer If m > n Then t = m: m = n: n = t '**********Program**********
'********** End ********** End Function
Private Sub Form_Load()
Show
Print fun(4, 2) NJIT_VB End Sub
Private Sub NJIT_VB() Dim i As Integer Dim a(10) As String Dim fIn As Integer Dim fOut As Integer fIn = FreeFile
Open App.Path & \ fOut = FreeFile
Open App.Path & \ For i = 1 To 10 Step 2 Line Input #fIn, a(i) Line Input #fIn, a(i + 1)
Print #fOut, Trim(Str(fun(Val(a(i)), Val(a(i + 1))))) Next
Close #fIn Close #fOut End Sub
18、题目:编写函数fun,函数的功能是:判断一个数是否为素数。并显示相应提示。如:
该数为素数时,显示\素数\;该数为非素数时,显示\非素数\要求使用For语句来实现,用布尔型变量flag作为该数是否为素数的标志,注意:不得使用Goto语句。
Private Function fun(m As Long) As String Dim flag As Boolean
'**********Program**********
'********** End ********** End Function
Private Sub Form_Load() Show
Print fun(225) NJIT_VB End Sub
Private Sub NJIT_VB() Dim i As Integer Dim a(10) As String Dim fIn As Integer Dim fOut As Integer fIn = FreeFile
Open App.Path & \ fOut = FreeFile Open App.Path & \ For i = 1 To 10 Step 1 Line Input #fIn, a(i)
Print #fOut, fun(Val(a(i))) Next
Close #fIn Close #fOut End Sub Next
Close #fIn Close #fOut End Sub
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库VB程序设计考试题库 - 考试专用在线全文阅读。
相关推荐: