2007年秋至2010年秋江苏省计算机二级VB考试真题及参考答案

发布时间 : 星期五 文章2007年秋至2010年秋江苏省计算机二级VB考试真题及参考答案更新完毕开始阅读

Dim St as string, L as Integer, I as integer L=Len(s)

Do while L>=1 st=Left(s,1) if st>\ st=Asc(st)-55 end if

Covert=Convert+Val(st)*N^(L-1) print Val(st)*N^(L-1) L=L-1

s=Right(S,L) Loop

End Function

5.窗体显示的第一行是__(13)___,第二行是__(14)____,第三行是___(15)__ Option Explicit

Private Sub Command1_Click()

Dim s as string, k as integer, ch() as string Dim P as string,i as integer

s=Ucase(\ For i=1 to Len(s)

If Mid(s,i,1)<=\ p=p & Mid(s,i,1) ElseIf p<>\ k=k+1

Redim Preserve ch(k) ch(k)=p p=\ End if Next i

For i=1 to Ubound(ch) if len(ch(i))<=2 then Call move_c(ch(i),1) else

Call move_c(ch(i),2) end if print ch(i) next i End Sub

Private Sub Move_c(s as string, k as integer) Dim i as integer, j as integer, p as string*1 For i=1 to k p=Right(s,1)

For j=Len(s)-1 to 1 step -1 Mid(s,j+1,1)=Mid(s,j,1)

Next j

s=p & Right(s,Len(s)-1) next i End Sub

6.下面的程序是求下式的近似值,当第n项的绝对值小于10^-5时终止计算 S=1-1/3+1/5-1/7+… option explicit

Private Sub Command1_Click()

dim n as long, s as single, t as single, pi as single Const eps=0.00001 n=1 t=1 s=0 do

s=s+t n=n+1

t=___(16)______

Loop Until __(17)______ pi=s*4

Label1.Caption =\的近似值为:\End Sub

7.下面程序的功能是,找出满足以下条件的三位整数,不含数字0,且任意交换数字位置所得到的数,均能被6整除 Option explicit

Private sub Command1_Click()

dim i as integer, j as integer, k as integer, st as string Dim a(6) as integer For i=100 to 999

if ______(18)_________ then For j=1 to 6

if a(j) Mod 6<>0 then Exit For Next j

if______(19)________THen st=st & str(i) k=k+1

if k mod 3 =0 then st=st & vbcrlf End if End if Next I Text1=st End Sub

Private Function fj(a() as integer, s as string) as Boolean Dim n as Integer, i as integer, j as integer if Instr(s,\

___(20)___ end if

For i=1 to 3 For j=1 to 2 n=n+1

____(21)___

s=Left(s,1) & Right(s,1) & Mid(s,2,1) Next j

s=Right(s,1) & left(s,2) Next i fj=True End Function

8.下面程序的功能是求两个特大整数之和,由于vb中能够表示的整数大小有一定限制,所以必须用新的方法求特大整数之和,本程序将特大整数使用字符类型进行处理,其中函数add用于求两个1位整数之和,参数c用于保存进位,注意,求和前需首先将两个整数按位对齐

option explicit

private Sub command1_Click()

Dim s1 as string, s2 as string, s3 as string dim i as integer, n1 as integer, n2 as integer dim c as integer, n as integer s1=text1 : s2=Text2 n=______22_____ if sgn(n)>0 then

s2=________23__________ elseif Sgn(N)<0 then

s1=String(Abs(n),\ end if

For i=len(s1) to 1 step -1 n1=Val(Mid(s1,i,1)) n2=Val(Mid(s2,i,1))

s3=_______(24)________ Next i

if c<>0 then s3=________(25)________ Text3=s3 End Sub

Private Function Add(x as integer, y as integer, c as Integer) as string Add=Cstr((x+y+c) Mod 10) _________(26)________ End Function

9. 下面程序功能是:找出各位数字互不相同,且其6倍数仍由组成该数的数字构成的六位整数。例如:126873的6倍数是761238,就是符合条件的数。

提示:程序中用a,b数组成标示数组元素下标值对应的数字是否出现在六位整数中。例如:2出现在某六位整数中,则a(2)的值为1。

Option Explicit

Private Sub Command1_Click()

dim i as long,i2 as long, flag as Boolean Dim a(0 to 9) as integer, b(0 to 9) as integer For i=100000 to 160000 Call Validate(i,a,flag) if flag then i2=i*6

call Validate(i2,b,flag)

if flag and Compare(a,b) then List1.AddItem i & \ \ End if End if Next i end sub

Private Sub validate(n as long, a() as Integer, f as Boolean) dim p as integer, i as integer Erase a f=false

for i=1 to len(cstr(N)) p=___(27)___ if a(p)=1 then exit sub else a(p)=1 end if next i

___(29) f=true End Sub

Private Function Compare(a() as integer, b() as integer) as Boolean dim j as integer compare=false

for j=1 to Ubound(a) if a(j)<>b(j) then

____(30)____exit function End if next j

Compare=true End Function

0回答者: 011467

2010年春江苏计算机等级vb上机 Option Explicit

Private Sub Command1_Click()

联系合同范文客服:xxxxx#qq.com(#替换为@)