南京工业大学VB考试操作题答案全解文档格式.docx

上传人:b****5 文档编号:15783944 上传时间:2022-11-16 格式:DOCX 页数:16 大小:143.96KB
下载 相关 举报
南京工业大学VB考试操作题答案全解文档格式.docx_第1页
第1页 / 共16页
南京工业大学VB考试操作题答案全解文档格式.docx_第2页
第2页 / 共16页
南京工业大学VB考试操作题答案全解文档格式.docx_第3页
第3页 / 共16页
南京工业大学VB考试操作题答案全解文档格式.docx_第4页
第4页 / 共16页
南京工业大学VB考试操作题答案全解文档格式.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

南京工业大学VB考试操作题答案全解文档格式.docx

《南京工业大学VB考试操作题答案全解文档格式.docx》由会员分享,可在线阅读,更多相关《南京工业大学VB考试操作题答案全解文档格式.docx(16页珍藏版)》请在冰豆网上搜索。

南京工业大学VB考试操作题答案全解文档格式.docx

fib=1

Else

fib=fib(x-2)+fib(x-1)

EndIf

EndFunction

PrivateSubCommand2_Click()

Text1="

"

Text2="

Text1.SetFocus

PrivateSubCommand3_Click()

End

2.百元百鸡

PrivateSubcmdCalc_Click()

'

变量说明

DimxAsInteger

DimyAsInteger

DimzAsInteger

穷举法计算

Forx=1To20

Fory=1To33

z=100-x-y

If5*x+3*y+z/3=100Then

Text1=Text1&

CStr(x)&

Space(6)&

CStr(y)&

CStr(z)&

Chr(13)&

Chr(10)

Nexty

Nextx

3.矩阵不靠边元素和

Forj=1To5

a(i,j)=Int(Rnd*90)+10

Next

Fori=1To5

Picture1.Printa(i,j);

Picture1.Print

Text1=fun1(a)

Functionfun1(x()AsInteger)AsDouble

DimiAsInteger,jAsInteger

fun1=0

Fori=LBound(x,1)ToUBound(x,1)

Forj=LBound(x,2)ToUBound(x,2)

IfNot(i=LBound(x,1)Ori=UBound(x,1)Orj=LBound(x,2)Orj=UBound(x,2))Then

fun1=fun1+x(i,j)

Picture1.Cls

Command1.SetFocus

PrivateSubCommand4_Click()

4.递归函数

List1.Clear

DimiAsInteger

Fori=1To7

List1.AddItemfact(i)

Nexti

Functionfact(ByValnAsDouble)AsDouble

Ifn=1Then

fact=1

fact=n*fact(n-1)

5.回文数

Randomize

DimiAsInteger,xAsInteger,minAsInteger

Fori=1To500

x=Int(Rnd*9000)+1000

x&

vbCrLf

IfHuiWenShu(x)Then

Text2=Text2&

Ifmin=0Then

min=x

Ifmin>

xThen

Text3=min

FunctionHuiWenShu(ByValaAsInteger)AsBoolean

IfStrReverse(a)=aThen

HuiWenShu=True

HuiWenShu=False

Text3="

6.级数求和。

DimsAsDouble,nAsLong

DimmAsDouble

s=0

n=1

Do

m=1/(2*n-1)

Ifm<

10^(-5)ThenExitDo

s=s+m

n=n+1

Loop

Text1=CStr(s)

7.矩阵转置

OptionBase1

Dima(4,4)AsInteger

DimbAsInteger,cAsInteger

DimiAsInteger,jAsInteger,tempAsInteger

Forb=1To4

Forc=1To4

a(b,c)=Int(Rnd*90)+10

a(b,c)&

"

Nextc

Nextb

Fori=1To4

Forj=1Toi-1

temp=a(i,j)

a(i,j)=a(j,i)

a(j,i)=temp

Nextj

Forj=1To4

a(i,j)&

8.靠边元素和。

Dima(1To4,1To4)AsInteger

a(i,j)=Int(Rnd*10)+0

Ifi=LBound(x,1)Ori=UBound(x,1)Orj=LBound(x,2)Orj=UBound(x,2)Then

9.孪生素数

Fori=2To998

IfIsPrime(i)AndIsPrime(i+2)Then

List1.AddItemCStr(i)&

&

CStr(i+2)

FunctionIsPrime(ByValnAsInteger)AsBoolean

Fori=2Ton-1

IfnModi=0ThenExitFunction

IsPrime=True

10.冒泡顺序

Dima(10)AsInteger

DimiAsInteger,jAsInteger,kAsInteger,tempAsInteger

Fori=1To10

a(i)=Int(Rnd*90)+10

a(i)&

Forj=1To9

Fork=1To10-j

Ifa(k)>

a(k+1)Then

temp=a(k)

a(k)=a(k+1)

a(k+1)=temp

Nextk

Forj=1To10

a(j)&

11.逆序数

PrivateSub

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1