亚洲精品中文字幕无乱码_久久亚洲精品无码AV大片_最新国产免费Av网址_国产精品3级片

計算機等級 百分網(wǎng)手機站

計算機二級vb考試試題附答案(3)

時間:2017-05-23 09:25:32 計算機等級 我要投稿

計算機二級vb考試試題(附答案)

  Option Explicit

  Option Base 1

  Private Sub Commandl_Ciick()

  Dim A(4,4)As Integer,i As Integer,j As Integer,k As Integer

  For i=1 To 4

  For j=1 To 4

  k=k+1

  A(i,j)=k

  Next j

  Next i

  Call Transform(A)

  For i=1 To 4

  For j=l To 4

  Text1=Text1 & Right(" " & A(i,j),3)

  Next j

  Text1=Text1 & vbCrLf

  Nexti

  End Sub

  Private Sub Transform(A() As Integer)

  Dim i As Integer,j As Integer,n As Intege,t As Integer,k As Integer

  n=UBound(A,1)

  k=n+1

  For i=1 To n/2

  For j=1 To n

  If i<>j And j<>k-i Then

  t=A(i,j)

  A(i,j)=A(k-i,k-j)

  A(k-i,k-j)=t

  End If

  Next j

  Next i

  End Sub

  3.執(zhí)行下面程序,單擊命令按鈕Cmd1后,窗體上顯示的第一行內(nèi)容是___(7)___,第二行內(nèi)容

  是___(8)___,第三行內(nèi)容是___(9)___。

  Option Explicit

  Private Sub Cmd1_Click()

  Dim st As String,ch As String*1,t As Integer

  Dim i As Integer

  st="2,3,8,12,32,65#"

  For i=1 To Len(st)

  ch=Mid(st,i,1)

  If ch<>"," And ch<>"#" Then

  t=t*10+Val(ch)

  Else

  If pd(t) Then Print t

  t=0

  End If

  Next i

  End Sub

  Private Function pd(ByVal n As Integer)As Boolean

  Do While n<>1

  If n Mod 2<>0 Then

  Exit Function

  EndIf

  n=n\2

  Loop

  pd=True

  End Function

  4.執(zhí)行下面程序,單擊命令按鈕CmdRun后,圖片框Pic1第一行顯示內(nèi)容是___(10)___,第二

  行顯示內(nèi)容是___(11)___,最后一行顯示內(nèi)容是___(12)___。

  Option Explicit

  Private Sub CmdRun_Click()

  Dim N As Integer,M As Integer

  M=135

  N=8

  Pic1.Print Fun(M,N)

  EndSub

  Private Function Fun(ByVal N As Integer,ByVal R As Integer)As String

  Dim L As Integer

  If N

  Fun=N

  Else

  L=N\R

  Fun=Fun(L,R)

  Fun=Fun & N Mod R

  End If

  Pic1.Print N

  End Function

  5.執(zhí)行下面程序,單擊命令按鈕CmdRun后,文本框Text1中第一行顯示的內(nèi)容是___(13)___ ,

  第二行顯示的內(nèi)容是___(14)___。第三行顯示的內(nèi)容是___(15)___ 。

  Option Explicit

  Private Sub CmdRun_Click()

  Dim S As String,Subs As String,P As Integer

  S="100101 010110 110101"

  Do

  P=InStr(S," ")

  If P<>0 Then

  Subs=Left(S,P-1)

  Else

  Subs=S

  End If

  S=Mid(S,P+1)

  Text1=Text1 & Complement(Subs) & vbCrLf

  Loop Until Len(S)=0 Or P=0

  End Sub

  Private Function Complement(S As String)As Integer

  Dim P As Integer,L As Integer

  L=Len(S)

  If Left(S,1)=1 Then

  Complement=-32

  End If

  P=1

  Do Until P=0

  P=InStr(P+1,S,"1")

  If P<>0 Then

  Complement=Complement+2^(L-P)

  End If

  Loop End Function

  6.本程序的功能是按公式求S的近似值(計算到第n項的絕對值小于等于10^-7為止)。

  S=x- + * +(-1) * 請完善本程序。

  Option Explicit

  Private Sub Command1_Click()

  Dim x As Single,n As Single,T As Single,S As Single

  x=Val(Text1)

  S=x

  Do

  ___(16)___

  T=afun(x,n)

  S=S+T

  Loop Until ___(17)___

  Text2=Format(S,"0.#######")

  End SUb

  Private Function afun(x As Single,n As Single)As Single

  Dim i As Single,p As Single

  P=1

  For i=1 To n

  p= ___(18)___

  Next i

  afun=(-1)^n*p*x^(2*n+1)/(2*n+1)

  End Function

  7.本程序的功能是找出10到60之間所有不可以表示成兩個平方數(shù)之和的數(shù),請完善本程序•

  Option Explicit

  Private Sub CmdFind_Click()

  Dim i As Integer,j As Integer,k As Integer

  Dim p As Integer,q As Integer

  For i=10 To 60

  For j=1 To Int(Sqr(i))

  ___(19)___

  q=i-P

  If q<>0 And judge(q) Then Exit For