vb习题.docx

上传人:b****7 文档编号:10791117 上传时间:2023-02-22 格式:DOCX 页数:22 大小:17.92KB
下载 相关 举报
vb习题.docx_第1页
第1页 / 共22页
vb习题.docx_第2页
第2页 / 共22页
vb习题.docx_第3页
第3页 / 共22页
vb习题.docx_第4页
第4页 / 共22页
vb习题.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

vb习题.docx

《vb习题.docx》由会员分享,可在线阅读,更多相关《vb习题.docx(22页珍藏版)》请在冰豆网上搜索。

vb习题.docx

vb习题

第一题

Dimroot(10)AsVariant

PrivateSubForm_Load()

DimepsAsSingle:

DimhAsSingle

DimaaAsInteger:

DimbbAsInteger

DimmAsInteger:

DimnAsInteger

DimiAsInteger:

DimpAsSingle

eps=0.0000001:

h=0.1

m=6:

aa=0:

bb=2

Callrt(aa,bb,h,m,n,eps)

Fori=1Ton

p=Round(root(i),6)

Debug.Print"x";i;"=";p

Debug.Print"x";i+2;"=";-p

Nexti

EndSub

Functionf(x)AsDouble

f=x^6-5*x^4+6*x-1

EndFunction

Subrt(aa,bb,h,m,n,eps)

n=0

DimaAsDouble:

DimbAsDouble

DimfaAsDouble:

DimfbAsDouble

DimcAsDouble:

DimfcAsDouble

DimdeltaAsDouble

a=aa:

fa=f(a)

Do

b=a+h:

fb=f(b)

c=0.5*(a+b)

fc=f(c)

delta=Abs(b-c)

Iffc*fa<0Then

b=c

Else:

a=c:

fa=fc

EndIf

LoopUntildelta<=eps

n=n+1:

root(n)=c

EndIf

a=b:

fa=fb

LoopUntilb>bbOrn>=m

EndSub

结果:

X1=.167316

X2=1.104632

X3=-.167316

X4=-1.104632

第二题

PrivateSubForm_Load()

DimkwjiAsInteger

a(0,0)=1.502:

a(0,1)=0.0514:

a(0,2)=0:

a(0,3)=0.0408

a(1,0)=0.0261:

a(1,1)=1.1516:

a(1,2)=0:

a(1,3)=0.082

a(2,0)=0.0342:

a(2,1)=0.0355:

a(2,2)=2.532:

a(2,3)=0.2933

a(3,0)=0.034:

a(3,1)=0.0684:

a(3,2)=0:

a(3,3)=0.0347

b(0)=0.1013:

b

(1)=0.09943:

b

(2)=0.2194:

b(3)=0.03396

kwji=0

CallSubMain(4,0.0000000001)

Fori=0To3

Debug.Printb(i)

Nexti

EndSub

PublicSubSubMain(nAsInteger,epAsDouble)

DimkAsInteger

Fori=0To99

m1(i)=i+1

Nexti

Fork=0Ton-1

Callcpe(n,k,ep)

Ifp>epThen

Forj=k+1Ton-1

a(k,j)=a(k,j)/a(k,k)

Nextj

b(k)=b(k)/a(k,k)

Fori=0Ton-1

If(i<>k)Then

Forj=k+1Ton-1

a(i,j)=a(i,j)-a(i,k)*a(k,j)

Nextj

b(i)=b(i)-a(i,k)*b(k)

EndIf

Nexti

Else

kwji=1

EndIf

Nextk

Fork=0Ton-1

a(0,m1(k)-1)=b(k)

Nextk

Fork=0Ton-1

b(k)=a(0,k)

Nextk

EndSub

PublicSubcpe(nAsInteger,kAsInteger,epAsDouble)

DimttAsDouble

DimiAsInteger,jAsInteger,i0AsInteger,j0AsInteger

p=Abs(a(k,k))

i0=k

j0=k

Fori=kTon-1

Forj=kTon-1

If(Abs(a(i,j))>p)Then

p=Abs(a(i,j))

i0=i

j0=j

EndIf

Nextj

Nexti

If(p>ep)Then

If(j0<>k)Then

Fori=0Ton-1

tt=a(i,j0)

a(i,j0)=a(i,k)

a(i,k)=tt

Nexti

tt=m1(k)

m1(k)=m1(j0)

m1(j0)=tt

EndIf

If(i0<>k)Then

Forj=kTon-1

tt=a(i0,j)

a(i0,j)=a(k,j)

a(k,j)=tt

Nextj

tt=b(i0)

b(i0)=b(k)

b(k)=tt

EndIf

EndIf

EndSub

结果:

b(0)=6.265669E-2b

(1)=7.950508E-2b

(2)=.0758797b(3)=7.605627E-2

第三题:

PrivateSubForm_Load()

DimmAsInteger,nAsInteger

m=3:

n=60

Dimy(2,60)AsSingle,yy(2,60)AsSingle

DimhAsInteger,iAsInteger,jAsInteger

DimlAsInteger,dAsInteger

Dimx(60)AsSingle,s(3)AsSingle

Dimk(2,4)AsSingle,pAsSingle

h=1

y(0,0)=0.01:

y(1,0)=0:

y(2,0)=0

s(0)=0:

s

(1)=0.5:

s

(2)=0.5:

s(3)=1

Forl=1Ton

Debug.Print"t=";l

Fori=1Tom

Forj=1To4

p=x(l-1)+s(j-1)*h

Ford=1Tom

yy(d-1,l-1)=y(d-1,l-1)+s(j-1)*k(d-1,j-1)

Nextd

SelectCasei

Case1

k(i-1,j)=-h*(0.0044+0.0021)*yy(0,l-1)

Case2

k(i-1,j)=h*(0.0044*yy(0,l-1)-2.96*yy(1,l-1))

Case3

k(i-1,j)=h*(2.96*yy(1,l-1)+0.0021*yy(0,l-1))

EndSelect

Nextj

x(l)=p

y(i-1,l)=y(i-1,l-1)+1/6*(k(i-1,1)+2*k(i-1,2)+2*k(i-1,3)+k(i-1,3)+k(i-1,4))

Debug.Print"c(";i;")=";y(i-1,1),

Nexti

Debug.Print

Nextl

EndSub

t=1

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=2

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=3

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=4

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=5

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=6

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=7

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=8

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=9

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=10

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=11

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=12

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=13

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=14

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=15

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=16

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=17

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=18

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=19

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=20

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=21

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=22

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=23

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=24

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=25

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=26

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=27

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=28

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=29

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=30

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=31

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=32

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=33

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=34

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=35

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=36

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=37

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=38

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=39

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=40

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=41

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=42

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=43

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=44

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=45

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=46

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=47

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=48

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=49

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=50

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=51

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=52

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=53

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=54

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=55

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=56

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=57

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=58

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=59

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

t=60

c

(1)=9.924413E-03c

(2)=8.033664E-06c(3)=6.755378E-05

第四题

第一小题

PublicaAsDouble

PublicbAsDouble

PublicrAsDouble

Dimya(0To13)AsDouble

Dimxa(0To13)AsDouble

PrivateSubForm_Load()

DimIAsInteger

Dimr0AsDouble

DimC(3)AsDouble

ya(0)=4896:

ya

(1)=4886:

ya

(2)=4875:

ya(3)=4865:

ya(4)=4855:

ya(5)=4845:

ya(6)=4834

ya(7)=4824:

ya(8)=4804:

ya(9)=4783:

ya(10)=4742:

ya(11)=4701:

ya(12)=4599:

ya(13)=4496

xa(0)=5:

xa

(1)=10:

xa

(2)=15:

xa(3)=20:

xa(4)=25:

xa(5)=30:

xa(6)=35

xa(7)=40:

xa(8)=50:

xa(9)=60:

xa(10)=80:

xa(11)=100:

xa(12)=150:

xa(13)=200

CallListq1(14)

Debug.Printa

Debug.Printb

Debug.Printr

EndSub

PublicFunctionListq1(mAsInteger)

DimX1,Y1,X2,Y2,XY,LXY,LYY,LXXAsDouble

DimI,JAsInteger

X1=Y1=X2=Y2=XY=0

ForI=0Tom-1

X1=X1+xa(I):

X2=X2+xa(I)*xa(I)

Y1=Y1+ya(I):

Y2=Y2+ya(I)*ya(I)

XY=XY+xa(I)*ya(I)

NextI

LXX=X2-X1*X1/m:

LYY=Y2-Y1*Y1/m:

LXY=XY-X1*Y1/m

b=LXY/LXX:

a=(Y1-b*X1)/m:

r=LXY/Sqr(-LXY*LYY)

EndFunction

结果:

4906.14584040747

-2.05005093378608

0.998419715160735

4.2

Dimm,nAsInteger

Dimax,a(7)AsDouble

Dimi,j,kAsInteger

Dims(14),t(7),b(7,8)AsDouble

Dimy(0To13)AsDouble

Dimx(0To13)AsDouble

Dimm1AsDouble,mmAsDouble

PrivateSubForm_Load()

DimiAsInteger

Dimr0AsDouble

DimC(3)AsDouble

m=14:

n=7

y(0)=4896:

y

(1)=4886:

y

(2)=4875:

y(3)=4865:

y(4)=4855:

y(5)=4845:

y(6)=4834

y(7)=4824:

y(8)=4804:

y(9)=4783:

y(10)=4742:

y(11)=4701:

y(12)=4599:

y(13)=4496

x(0)=5:

x

(1)=10:

x

(2)=15:

x(3)=20:

x(4)=25:

x(5)=30:

x(6)=35

x(7)=40:

x(8)=50:

x(9)=60:

x(10)

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

当前位置:首页 > 高等教育 > 哲学

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

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