vb课后习题答案华中科技大学独家Word下载.docx

上传人:b****2 文档编号:4697581 上传时间:2023-05-03 格式:DOCX 页数:24 大小:19.27KB
下载 相关 举报
vb课后习题答案华中科技大学独家Word下载.docx_第1页
第1页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第2页
第2页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第3页
第3页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第4页
第4页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第5页
第5页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第6页
第6页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第7页
第7页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第8页
第8页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第9页
第9页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第10页
第10页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第11页
第11页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第12页
第12页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第13页
第13页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第14页
第14页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第15页
第15页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第16页
第16页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第17页
第17页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第18页
第18页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第19页
第19页 / 共24页
vb课后习题答案华中科技大学独家Word下载.docx_第20页
第20页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

vb课后习题答案华中科技大学独家Word下载.docx

《vb课后习题答案华中科技大学独家Word下载.docx》由会员分享,可在线阅读,更多相关《vb课后习题答案华中科技大学独家Word下载.docx(24页珍藏版)》请在冰点文库上搜索。

vb课后习题答案华中科技大学独家Word下载.docx

x=Console.ReadLine

Inputy="

y=Console.ReadLine

{0}{1}"

表达式1的结果为"

Math.Sin(x)+Math.Cos(y))

表达式2的结果为"

((x^2+y^2)/Math.Abs(y))^(1/3))

表达式3的结果为"

x+y>

x^2-10*x)

 

B3PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click

TextBox1.Text=Int(Rnd()*100+-49)

EndSub

PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.Click

TextBox1.Text=Int(Rnd()*9998+1)*0.01

B4Randomize()

Label1.Text=Int(Rnd()*9000+1000)

Dima,b,c,dAsInteger

a=Label1.Text\1000

b=(Label1.TextMod1000)\100

c=(Label1.TextMod(a*1000+b*100))\10

d=(Label1.TextMod10)

Label2.Text=c*1000+a*100+d*10+b

B5DimaAsDouble

a=TextBox1.Text

Label1.Text=Format(a,"

##,###.0000"

Label2.Text=a

B10TextBox1.Text=UCase(TextBox1.Text)

TextBox1.SelectionStart=Len(TextBox1.Text)

B6Dima=TextBox1.Text

Label1.Text=Microsoft.VisualBasic.Left(a,16)

Label2.Text=Mid(a,17,6)

Label3.Text=Microsoft.VisualBasic.Right(a,5)

B7

Dima,bAsString

b=TextBox2.Text

Label1.Text=Replace(a,b,"

B8PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click

DimF=Val(TextBox1.Text),C=Val(TextBox2.Text)

C=(5/9)*(F-32)

TextBox1.Text=Math.Round(C,2)

F=(9/5)*C+32

TextBox2.Text=Math.Round(F,2)

B9PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click

Dimp=3.14,a=Val(TextBox1.Text)

TextBox2.Text=Format(p*a*a,"

##.00"

TextBox3.Text=Format(2*p*a,"

PrivateSubTextBox1_KeyPress(ByValsenderAsObject,ByValeAsSystem.Windows.Forms.KeyPressEventArgs)HandlesTextBox1.KeyPress

Ife.KeyChar=Chr(13)Then

IfIsNumeric(TextBox1.Text)=FalseThen

MsgBox("

输入非法字符,请重新输入"

0,"

友情提示"

TextBox1.Text="

TextBox1.Focus()

EndIf

C1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click

Dimp=3.14,a=Val(TextBox1.Text),b=Val(TextBox2.Text)

TextBox2.Text=2*p*a

TextBox3.Text=p*a*a

输入值不合法"

C2Dimx,yAsSingle

x=InputBox("

输入x="

Ifx>

20Then

y=x^2+3*x+2

结果为"

&

y)

ElseIfx<

10Then

y=0.5+Math.Abs(x)

Else

y=(3*x)^0.5-2

或者Dimx,yAsSingle

x=Val(TextBox1.Text)

SelectCasex

CaseIs<

10

CaseIs>

20

CaseElse

EndSelect

C3Dima,b,cAsSingle

a=InputBox("

输入a:

b=InputBox("

输入b:

c=InputBox("

输入c:

Ifa+b>

cAndb+c>

aAnda+c>

bThen

Ifa=bAndb=cThenMsgBox("

等边"

Ifa^2+b^2=c^2Ora^2+c^2=b^2Orb^2+c^2=a^2ThenMsgBox("

直角"

If(a=bXorb=c)Or(a=cXora=b)ThenMsgBox("

等腰"

C4Dima,b,cAsInteger

Randomize()

Label1.Text=Int(Rnd()*(900)+100)

a=Label1.Text\100

b=(Label1.TextMod100)\10

Label3.Text=b

c=Label1.TextMod10

Label4.Text=c

C5Dima,b,cAsInteger

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

b=Int(Rnd()*90+10)

c=Int(Rnd()*4+0)

SelectCasec

Case0

Label1.Text=a+b

Case1

Label1.Text=a*b

Case2

Label1.Text=a/b

Case3

Label1.Text=a-b

EndSelect

C6

PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click

Dima,bAsSingle

Ifa>

5000Then

Label5.Text="

八折"

:

Label6.Text=a*0.8

ElseIfa>

3000Then

八五折"

Label6.Text=a*0.85

2000Then

九折"

Label6.Text=a*0.9

1000Then

九五折"

Label6.Text=a*0.95

原价"

Label6.Text=a

Label6.Text="

C7Dimx,y,z,t

x=Val(InputBox("

输入x"

))

y=Val(InputBox("

输入y"

z=Val(InputBox("

输入z"

Label4.Text=x:

Label5.Text=y:

Label6.Text=z

Ifx<

yThen

t=x:

x=y:

y=t

Ifz>

xThen

t=y:

y=x:

x=z:

z=t

ElseIfz>

y=z:

z=y:

y=x

t=y:

EndIf

Label9.Text=x:

Label10.Text=y:

Label11.Text=z

EndSub

C8Dima,b,cAsDouble

a=TextBox1.Text:

b=TextBox2.Text:

c=TextBox3.Text

Ifb^2-4*a*c<

0Then

TextBox4.Text="

无解"

TextBox5.Text="

ElseIfb^2-4*a*c=0Then

TextBox4.Text=(-b+Math.Sqrt(b^2-4*a*c))/2

TextBox5.Text=(-b+Math.Sqrt(b^2-4*a*c))/2

TextBox5.Text=(-b-Math.Sqrt(b^2-4*a*c))/2

D1Dima,b,x

Fori=1To100

x=0.01*Int(Rnd()*99+1)

Ifx<

0.5Then

a=a+1

ElseIfx>

=0.5Then

b=b+1

Next

正面"

a&

"

%"

反面"

b&

D2Dima,b,i

Fori=2To100

Fora=2Toi-1

IfiModa=0Then

ExitFor

Next

Ifa>

i-1Then

b=b&

String.Format(Str(i))

Label1.Text=b

D3

IfTextBox1.Text="

111"

AndTextBox2.Text="

Then

登录成功!

提示信息"

登录失败!

TextBox2.Text="

n=n+1

Ifn>

=3ThenMsgBox("

3次登录失败!

):

End

D4Dimm%,n%,x%,y%,f%

m=Val(TextBox1.Text)

n=Val(TextBox2.Text)

IfnMod2<

脚数必须为偶数,请重新输入"

Fori=0Tom

f=m-i

Ifn=2*i+4*fThen

x=i

y=f

EndIf

TextBox3.Text=x

TextBox4.Text=y

0Ory<

数据错误"

D5DimnAsInteger,mAsSingle

n=Val(TextBox1.Text)

m=2

Fori=1Ton

m=m*((2*i)^2/((2*i-1)*(2*i+1)))

TextBox2.Text=m

EndSub

D6秋水仙花数

Dima,b,c,d,n

Forn=100To999

a=n\100

b=(nMod100)\10

c=nMod10

Ifn=a^3+b^3+c^3Then

d=d&

String.Format(Str(n))

Label1.Text=d

D7

DimiAsInteger=1,a,sumAsDouble

a=1

sum=1

Do

a=1/((1/a)+i)

sum=sum+a

i=i+1

LoopUntila<

10^(-4)

MsgBox(sum)

D8金字塔

Dimi,jAsInteger,s,aAsString

s="

Fori=1To9

s=s+Space(9-i)

a=i

Forj=1To2*i-1

s=s+a

Nextj

s=s+vbCrLf

Nexti

Label1.Text=s

D9迭代法求立方根

Dimx1#,x0#,t#,a#,i#

Fori=3To27

x0=i

a=x0

x1=(2/3)*x0+(a/(3*x0*x0))

t=x0

x0=x1

LoopUntilMath.Abs(x0-t)<

10^(-5)

Ifi=3ThenTextBox1.Text=x1

Ifi=27ThenTextBox3.Text=x1

TextBox2.Text=3^(1/3)

TextBox4.Text=27^(1/3)

D10Dimi,jAsInteger,m,n,aAsSingle

Fori=1To30

m=m+10000

a=0.01

Forj=1To30

n=n+a

a=a*2

Label1.Text=Format(m,"

##,###.00"

Label2.Text=Format(n,"

数组

E1Dima,b,n

a=Val(TextBox1.Text)

b=Val(TextBox2.Text)

n=Val(TextBox3.Text)

IfaMod1<

输入整数!

IfbMod1<

TextBox2.Focus()

IfnMod4<

TextBox3.Focus()

输入n为4的倍数!

EndIf'

以上为数据准备

Dimc(0Ton-1),i,s

Fori=0Ton-1

c(i)=Int(Rnd()*(b-a+1)+a)

s=s+Str(c(i))+"

If(i+1)Mod4=0Then

MsgBox(s)'

以上为准备随机数

Dimmax=c(0),min=c(0)

Ifc(i)>

maxThenmax=c(i)

Ifc(i)<

minThenmin=c(i)

Next'

以上为求最大值最小值

最大值为"

max&

最小值为"

min)

Dimave,sum

sum=sum+c(i)

ave=sum/n'

以上为求平均值

平均值为"

ave)

E2ModuleModule1

SubMain()

DimarrA(99),arrB(127),a,x,z,iAsInteger,y,bAsString

b=0

Fori=0To99

arrA(i)=Int(Rnd()*128)

Forj=0To99

Form=0To127

IfarrA(j)=mThen

arrB(m)=arrB(m)+1

Fora=48To57

b=Chr(a)

I

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

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2