云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 江苏省计算机二级vb分章节解析

江苏省计算机二级vb分章节解析

  • 62 次阅读
  • 3 次下载
  • 2025/5/4 18:27:41

X=Y-1+N Y=X+Y-N Fun=X+Y End Function 【答案】(1)10(2)27(3)9

8.执行下面程序,单击按钮Command1,窗体上显示的结果中I的值是____1____,J的值是____2____,K的值是_____3_____。

Option Explicit

Private Sub Command1_Click() Dim I As Integer, j As Integer Dim K As Integer I=1: J=2

K=Fun(I, Fun(I, J))+I+J Print \End Sub

Private Function Fun(A As Integer, ByVal B As Integer)As Integer A=A+B B=A+B Fun=A+B End Function 【答案】(1)11(2)2(3)43

9.本程序的功能是从给定的纯英文字符串中找出最长的一个按字母顺序排列的子串。程序界面参见图1。

Option Explicit

Private Sub Command1_Click() Dim st As String st=Text1

Text2=max_st(st) End Sub

Private Function max_st(st As String)As String

Dim i As Integer, sta As String 图 1 Dim P As String P=Mid(st, 1, 1)

For i=1 To Len(st)-1

If Asc(Mid(st, i+1, 1))-Asc(Mid(st, I, 1))=1 Then

______1______ Else

If Len(P)>1 And Len(p)>Len(sta) Then

Sta=_____2_____

End If

_____3______

End If Next i

If Len(P)>1 And Len(P)>Len(sta) Then ______4_____ E1se

Max_st=sta End If End Function 【答案】(1)P = P + Mid(st, i + 1, 1)(2)p(3)P = Mid(st, i + 1, 1)(4)max_st = P 10.下面程序的功能是找出由两个不同的数字组成的回文平方数。程序界面参见图2。

Option Explicit

Private Sub Command1_Click()

Dim A(0 To 9) As Integer, I As Long, Flg As Boolean Dim L As Long, J As Integer, Sum As Integer For I=10 To 1000 L=I* I

____1_____

Call ____2____ If Flg then For J=0 To 9

Sum=Sum+A(J) Next J

If Sum=2 Then

List1. AddItem CStr(I) & \& Str(L)

End If

End If 图 2 Sum=0 Next I End Sub

Private Sub Sub1(byval X As Long, A()As Integer, BL As Boolean) Dim N As Integer, Idx As Integer, I As Integer BL=False

N=Len(CStr(X)) For I=1 To N/2

If _____3______ Then Exit Sub End If Next I BL=True For I=1 To N

Idx=X Mod 10 _____4______

X=(X\\10) Next I End Sub

【答案】(1)Erase A(2)Sub1(L, A, Flg)(3)Mid(CStr(X), I, 1) <> Mid(CStr(X), N - I + 1, 1)(4)A(Idx) = 1

11.下面程序的功能是随机生成10个不同的两位数,从中找出所有互质数对。若两个数除了1以外没有其他公约数,这两个数就是互质数。其中函数Rec是一个递归函数。程序界面参见图3。

Option Explicit

Private Sub Command1_Click()

Dim A(10)As Integer, I As Integer, J As Integer Dim N As Integer, K As Integer Randomize

A(1)=Int(90*Rnd)+10 Text1=A(1) _____1_____ Do _____2_____

N=Int(90*Rnd)+10 If _____3______ (Text1,CStr(N))=0 Then

Text1=Text1 & Str(N)

K=K+l 图 3 A(K)=N End If Loop

For I=1 To 9

For J=I+1 To 10

If Not Rec(A(I), A(J), 2) Then

List1.AddItem Str(A(I)) & Str(A(J)) End If Next J Next I End Sub

Private Function Rec(N As Integer, M As Integer, K As Integer)As Boolean If K>N Then _____4_____

E1se

If N Mod K=0 And M Mod K=0 Then Rec=True

_____5_____ E1se

_____6______ End If End If End Function 【答案】(1)k=1(2)While K < 10(3)InStr(4)Exit Function(5)Exit Function(6)Rec = Rec(N, M, K + 1)

12.执行下面程序,单击按钮Command1,窗体上显示的第一行是____1_____,第二行是____2____。

Private Sub Command1_Click()

Dim x As Integer, y As Integer, Z As Integer X=6: y=12: Z=20 Print fun1(x, y)

Print fun1(fun1(x, y), z) End Sub

Private Function fun1(a As Integer,b As Integer)As Long Dim Y As Integer Y=a DO

If y Mod b=0 Then Fun1=y

Exit Function Else

y=y +a End If Loop End Function 【答案】(1)12(2)60

13.执行下面程序,单击按钮Command1,窗体上显示的第一行是_____1_____,第二行是____2____。

Option Explicit Dim a As Single

Private Sub Command1_Click() Dim a As Single, b As Integer a=1. 2: b=3 Print fun1(a, b) Print a End Sub

Private Function fun1(x As Single, y As Integer)As Integer Dim i As Integer For i=1 To y x=x*2 a=a+1 Next i Fun1=a End Function 【答案】(1)3(2)9.6

14.执行下面程序后,单击按钮Command1,窗体上第一行显示的内容是____1____,第二行显示的内容是_____2____,第三行显示的内容是____3_____。

Private Sub Command1_Click()

Dim X As Integer, Y As Integer, S As Integer

搜索更多关于: 江苏省计算机二级vb分章节解析 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

X=Y-1+N Y=X+Y-N Fun=X+Y End Function 【答案】(1)10(2)27(3)9 8.执行下面程序,单击按钮Command1,窗体上显示的结果中I的值是____1____,J的值是____2____,K的值是_____3_____。 Option Explicit Private Sub Command1_Click() Dim I As Integer, j As Integer Dim K As Integer I=1: J=2 K=Fun(I, Fun(I, J))+I+J Print \End Sub Private Function Fun(A As Integer, ByVal B As Integer)As In

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com