收藏 分销(赏)

【Visual Basic 程序设计教程】课后习题及参考答案.pdf

上传人:曲**** 文档编号:228588 上传时间:2023-03-16 格式:PDF 页数:45 大小:2.33MB
下载 相关 举报
【Visual Basic 程序设计教程】课后习题及参考答案.pdf_第1页
第1页 / 共45页
【Visual Basic 程序设计教程】课后习题及参考答案.pdf_第2页
第2页 / 共45页
【Visual Basic 程序设计教程】课后习题及参考答案.pdf_第3页
第3页 / 共45页
【Visual Basic 程序设计教程】课后习题及参考答案.pdf_第4页
第4页 / 共45页
【Visual Basic 程序设计教程】课后习题及参考答案.pdf_第5页
第5页 / 共45页
点击查看更多>>
资源描述

1、Vi sua I Bas ic程序设计教程参考答案第一章1、B2、A3、B4、答:属性:红色、充满氢气;事件:松手、针刺;方法:飞走、爆破。5、答:事件是指对象能够识别并作出反映的外部刺激。事件驱动又称消息驱动,事件驱 动程序设计是指每个事件对应有相应的程序代码,仅在该事件发生时,该段代码才会 被执行。事件发生的顺序决定了代码执行的顺序,因此每次执行应用程序时,程序代 码并不是按照程序编写的顺序来执行的。6、答:VB是一个包括界面设计、程序编码、调试、编译并创建可执行程序的集成开发环 境。VB的集成开发环境的主界面中包含:标题栏、菜单栏、工具栏、控件箱、工程资 源管理器、属性窗口、“窗体布局”

2、窗口、窗体设计器、代码编辑器等元素组成。7、答:VB菜单条通常情况下有:文件、编辑、视图、工程、格式、调试、运行、查询、图表、工具、外接程序、窗口、帮助等13项菜单项组成。8、答:工具栏可自行定义。标准工具栏中通常情况下有:添加标准exe工程、添加窗 体、菜单编辑器、打开工程、保存工程、剪切、复制、粘贴、查找、撤消、重复、启 动、中断、结束、工程资源管理器、属性窗口、窗体布局窗口、对象浏览器、工具 箱、数据视图窗口、可视化元件管理器等按钮组成。9、答:创建VB应用程序的一般步骤为:创建界面;设置窗体和控件属性;编写代码;保 存工程;运行并调试程序;检查并排除错误;创建可执行文件。10、Priv

3、ate Sub Commandl_Click()Labell.Caption=I love vb,I hate vb”End Sub第一早3、S1 输入待判断自然数:N(N=2);S2 i=2;S3判断i是否小于NT,若不是转S5S4判断N除以i的余数是否为0,如果不是则i=i+l转S3;S5判断i是否等于N,若是输出“是素数”,否则输出“不是素数二4、S1 输入待判断自然数:N;S2将N转换成字符S,计算S的长度K;S3 i=l;S4判断i是否小于KT,若不是转S6;S5判断S中的第i位和第K-i+1位是否相等,如果是则i=i+l转S4,如果不是则转S6;S6判断i是否是中间位数,若是输出“

4、是回文数”,否则输出“不是回文数二5、S1 输入待判断自然数:a;S2 i=l;S3判断i是否小于a-1,若不是转S5S4判断a除以i的余数是否为0,如果是则保留因子i,否则i=i+l转S3;S5输出所有因子。第三章1、窗体的属性主要分为杂项、外观、行为、字体、位置等五类。Caption是窗体标题,出现 在窗体标题栏的文本内容;而Name是窗体名称,在程序代码中被作为窗体的标识名。2、ABDE4、改变窗口的工作状态会引发Activate事件,改变窗口大小会引发resize事件。5、forecolor和backcolor属性首先选择系统中的选项,然后在调色板中设置相应的颜色;font属性设置好以

5、后,在窗体上放置的任何控件都会继承窗体的font属性。6、C7、Label、optionbutton、checkbox commandbutton 有 caption 属性,没有 text 属性;text combobox 有 text 属性,没有 caption 属性8、对象的属性可以在设计界面时在属性窗口中和运行中在代码中设置;属性窗口中的属性 列表并没有包括对象的所有属性。9、picturebox、frame 等10、optionbutton 和 checkboxo Optionbox 的 Value 可以取 true一选中和 false一未选中,checkbox的Value可以取0 未

6、选中,1一选中,2变灰,表示暂时不能访问。11 text commandbutton可以获得焦点。在设计界面时第一个放在窗体上的文本框或命令 按钮将得到焦点。12、C13、把Value的值设为2,表示暂时不能访问复选框,点击复选框后就可以访问了,而把 enabled属性设为false则是复选框变灰,完全不能访问。若把一个控件的Visible属 性设为false则在程序运行时看不到该控件。14用additem来添加列表项,用removeitem删除用有的列表项,用clear删除所有列表 项。15、学院:|电子工程勺 系科:|电子工程一3注册日期 厂 一年 一月 日注册 取消16、大小r 12号C

7、 14号字体r宋体r隶书G黑体字型V斜体V粗体退出Private Sub Checkl_Click()I f Checkl.Value=1 ThenLabel2.Font.I talic=TrueElself Checkl.Value=0 ThenLabel2.Font.I talic=FalseEnd I fEnd SubPrivate Sub Check2_Click()I f Check2.Value=1 ThenLabel2.Font.Bold=TrueElself Check2.Value=0 ThenLabel2.Font.Bold=FalseEnd I fEnd SubPriva

8、te Sub Commandl_Click()EndEnd SubPrivate Sub Optionl_Click()I f Optionl.Value Then Label2.Font.Size=12Label2.RefreshEnd SubPrivate Sub 0ption2_Click()I f 0ption2.Value Then Label2.Font.Size=14Label2.RefreshEnd SubPrivate Sub 0ption3_Click()I f 0ption3.Value Then Label2.Font.Size=16Label2.RefreshEnd

9、SubPrivate Sub 0ption4_Click()I f 0ption4.Value Then Label2.Font.Name=宋体”Label2.RefreshEnd SubPrivate Sub 0ption5 _Click()I f 0ption5.Value Then Label2.Font.Name=隶书Label2.RefreshEnd SubPrivate Sub Option6_Click()I f 0ption6.Value Then Label2.Font.Name=黑体”Label2.RefreshEnd Sub17、18、第四章1.B2.见教材P40-413

10、.不对,通用过程也可以存在于窗体模块中4.见教材P435.字符串型常量的界定符是双引号,日期型数据的界定符是磅号#。A、B是字符型,C、D是日期型,E、F不属于任何类型。6.合法变量名有:A、C、D(VB中合法变量名只能由字母、数字和下划线构成,并且只能以字母开头)7.见教材P468.(1)a/(b+c/d)(2)(sqr(x 2+1)+x)|(1/3)(3)(2*y)/(a*x+b*y)*(a*x1b*y)(4)1+1/(1+1/m)(5)(d/3)-(2*x)/2(6)log(y+cos(x)2)(7)fabs(exp(x)+sin(x)3)/(x+y)(8)log(exp(x*y)+fa

11、bs(tan(z)-l+cos(x)3)/(x+y-z)9.(1)(2)(A+B)/(A-B)(3)(4)A*B*C/(D+1)*Y)(5)(6)(X*Y)-510.A x+y0B x*y0 and x=fix(x)and y=fix(y)C A=0 XOR B=0D Cl+C2+C3=25 5 and Cl90 and C290 and C38011.T F F F F12.BCDE(A会发生溢出的错误)13.(1)35 48”(2)35 48(3)35 48”(4)35 48(5)“83(6)83(7)“35 48”(8)35 4814.以2为底的X的对数:log(x)/log15.C16

12、.z=I nputbox(输入一个数:,程序示例,1.5)17.Msgbox Z的值1.5大于0,48,程序示例18.Option ExplicitConst PI As Single=3.1415 9Private Sub Commandl_Click()Dim a As Single,b As Single,c As Single,area As Singlea=Vai(Textl.Text)b=Vai(Text2.Text)c=Vai(Text3.Text)*PI/180 角度角转换为弧度角area=a*b*Sin(c)/2Text4=CStr(Format(area,0.00)使纯小数

13、能出现整数位的0End SubPrivate Sub Command2_Click()Textl.Text=Text2.Text=Text3.Text=End SubPrivate Sub Command3_Click()EndEnd Sub1.第五章Option ExplicitPrivate Sub Commandl_Click()Dim a As I nteger,b As I nteger a=1:b=0Do While a=20 Then Exit For 跳出循环前执行不到这一句Next i Print i,pEnd SubPrivate Sub Command4_Click()D

14、im p As I nteger,i As I nteger,n As I ntegerp=2:n=20For i=1 To n Step p 计数循环的初值、终值和步长都不会变P=P+2n=n-3i=i+1I f p=10 Then Exit ForNext iPrint i,p,nEnd Sub2.FofmIbH73 5814 4757 7984 8419 9936 44 46 4791 3360 7256 51 41 46 34 15 31 98小于等于40的数据个数为:34个大于4。小于等于70的数据个数为:35个 大于70的数据个数为:31个62 3687 8114 6363 987

15、0 1137 9574 3980 4492 8537 7943 9652 3691 3061 1998 4666 2836 9212 5811 7888 1566 6872 9819 8135 2426 6266 6692 4883 7395 4233 3531 5835 1424 6817 5148 1871 5515 45生成10。个随机数统计个数清除Option ExplicitDim nl As I nteger,n2 As I nteger,n3 As I ntegerPrivate Sub Command1_C1ick()Dim i As I nteger,j As I ntege

16、r,k As I ntegerFor i=1 To 10For j=1 To 10 k=I nt(Rnd*90+10)Print k;I f k=40 Thennl=nl+1Elself k=7 0 Then n2=n2+1Else n3=n3+1End I fNext j PrintNext iEnd SubPrivate Sub Command2_Click()Print 小于等于40的数据个数为:&nl&个Print 大于40小于等于70的数据个数为:&n2&个Print 大于70的数据个数为:&n3&个End SubPrivate Sub Command3_Click()CisEnd

17、SubOption ExplicitPrivate Sub Command1_C1ick()Dim x As I nteger,y As I nteger x=Textl.TextI f x=0 Theny=2-x Elself x=2 Then y=x+2 Elself x=5 Then y=x-2 Elsey=25-x End I fText2.Text=yEnd SubPrivate Sub Command2_Click()Textl.Text=Text2=End SubOption ExplicitPrivate Sub Command1_Click()Dim i As I ntege

18、r,j As I nteger,k As I nteger For i=1 To 2For j=1 To 10k=I nt(Rnd*900+100)Picturel.Print k;I f k Mod 200 ThenListl.Additem kElseList2.Additem kEnd I fNext jPicturel.PrintNext iEnd SubOption Explicit5.Private Sub Command1_Click()Dim m As I nteger,n As m=Vai(Textl.Text)n=Vai(Text2.Text)Dor=m Mod nI f

19、r 0 Thenm=nn=r ElseExit DoEnd I fLoopText3.TextI nteger,r As I ntegerVai(Textl.Text)*Vai(Text2.Text)/nEnd Sub6.Option ExplicitDim rl As I nteger,r2 As Single r2可能是个很大的数,最好定义成单精度 型Private Sub Command1_Click()Dim i As I nteger,k As I ntegerrl=0:r2=1 r2 一定要初始化为1,否则积为0For i=1 To 10k=I nputBox(请输入第&i&个数)

20、Picturel.Print k;rl:r2:Next i End Sub Private Sub Textl=End Sub Private Sub Text2=End Subrl+k r2*kCommand2_Click()rlCommand3_Click()r27.FofmI请输入字母数字串:所有的数字的为:Option ExplicitPrivate Sub Commandl_Click()Dim s As String,si As String,s2 As String,i As I nteger si=Textl.Text For i=1 To Len(si)s=Mid(si,i,

21、1)I f s=0 And s=9 Then s2=s2&s End I f Next i Text2.Text=s2 End Sub8.Option ExplicitPrivate Sub Commandl_Click()Textl=Text2=End SubPrivate Sub Command2_Click()Dim n As I nteger,r As String,s As Stringn=Vai(Textl.Text)Dor=n Mod 2 s=r&s n=n 2Loop Until n=0 当商为0时则跳出循环Text2.Text=sEnd Sub 9.Option Explic

22、itPrivate Sub Commandl_Click()Dim a As Long,b As Long,c As LongFor a=1 To 100For b=1 To 100For c=1 To 100I fa*a+b*b=c*c ThenListl.Addltem a&,&b&cEnd I fNext cNext b Next a End Sub10.Option ExplicitPrivate Sub Commandl_Click()Dim i As I nteger,rl As I nteger,r2 As I nteger,r3 As I nteger For i=100 To

23、 999 rl=i 100 r2=(i 10)Mod 10 或者 r2=(i mod 100)10 r3=(i Mod 100)Mod 10 I f rl r2 And r2 0 Then a-cElse b=cEnd I fc=(a+b)/2Loop Until Abs(b-c)20 Then p=p-20 n=n+a(p)Next j I f n max Then max=n w=i End I f Next i Text2=max Picturel.Print w&一&w+4 End Sub Private Sub Command3_Click()Textl=End SubPrivate

24、 Sub Command4_Click()End End Sub 6-5Dim a(5,5)As I ntegerPrivate Sub Commandl_Click()For i=1 To 4For j=1 To 5a(i,j)=I nt(9*Rnd)+1Picturel.Print a(i,j);Next jPicturel.PrintNext iEnd SubPrivate Sub Command2_Click()For j=1 To 5s=0For i=1 To 4s=s+a(i,j)Next iTextl=Textl&Str(s)Next jEnd SubPrivate Sub Co

25、mmand3_Click()For i=1 To 4s=0For j=1 To 5s=s+a(i,j)Next jText2=Text2&Str(s)&Chr(13)&Chr(10)Next iEnd SubPrivate Sub Command4_Click()Textl=Text2=Picturel.CisEnd SubPrivate Sub Command5 _Click()EndEnd Sub6-6Option ExplicitPrivate Sub Command1_C1ick()Dim a(5,5),i As I nteger,j As I ntegerDim n As I nte

26、ger,m As I nteger,t As I ntegerRandomizeFor i=1 To 5For j=1 To 5-1a(i,j)=I nt(40*Rnd)*2+10Next jNext iFor i=1 To 5For j=5 To 6-i Step-1a(i,j)=I nt(40*Rnd)*2+11Next jNext iFor i=1 To 5For j=1 To 5Textl=Textl&Str(a(i,j)Next jTextl=Textl&vbCrLfNext iEnd Sub6-7 同 6-46-8Dim a(5,5)As I ntegerPrivate Sub C

27、ommandl_Click()RandomizeFor i=1 To 5For j=1 To 5a(i,j)=I nt(100*Rnd)+1Picturel.Print Right(,/”&a(i,j),4);Next j Picturel.PrintNext iEnd SubPrivate Sub Command2_Click()For i=1 To 5For j=1 To 5s=s+a(i,j)Next j Next i Textl=Str(s)End SubPrivate Sub Command3_Click()For i=1 To 5For j=1 To 5I fi=10rj=10ri

28、=5 0rj=5 Then s=s+a(i,j)End I fNext jNext iText2=Str(s)End SubPrivate Sub Command4_Click()For i=1 To 5For j=1 To 5I f i=j0rj=6-i Thens=s+a(i,j)End I f Next jNext iText3=Str(s)End Sub6-9Option ExplicitPrivate Sub Commandl_Click()Dim a()As I nteger,i As I nteger,j As I ntegerDim max As I nteger,k As I

29、 nteger,f As BooleanDim n As I nteger,m As I nteger,t As I ntegern=I nputBox(输入矩阵的行数:”)m=I nputBox(输入矩阵的列数:”)ReDim a(n,m)RandomizeFor i=1 To nFor j=1 To ma(i,j)=I nt(90*Rnd)+10Textl=Textl&Str(a(i,j)Next jTextl=Textl&vbCrLfNext iFor i=1 To nmax=0For j=1 To mI f a(i,j)max Then max=a(i,j)t=jEnd I fNext

30、 jFor k=1 To nI f a(k,t)n ThenPicturel*Print 鞍点:”;a(i,t);第;i;行;t;列 f=TrueEnd I fNext iI f f=False Then Picturel.Print”没有鞍点”End SubPrivate Sub Command2_Click()Textl=Picturel.CisEnd SubPrivate Sub Command3_Click()EndEnd Sub6-10 6-10杨辉三角 叵|区|Option ExplicitPrivate Sub Form_Click()Dim a()As I nteger,n A

31、s I ntegerDim i As I nteger,j As I ntegern=I nputBox(层数)ReDim a(n,n)For i=1 To nPrint Tab(20For j=1 ToI f i:a Else a=1 i(i,(i,i Or j)j)i=j Then=1=a(i-1,j-1)+a(i-1,j)-2*i);6-11End I fPrint Left(a(i,j)&,4);Next jPrintNext iEnd Sub教组行交换6Tl13回区I2 7 8 28 5 7 92 3 4 113 3 73 3 4 53 3 5 50 6 4 47 2 3 38 4

32、6 82 2 2 3运行2 2 8 78 9 7 52 14 317 3 33 5 4 33 5 5 30 4 4 67 3 3 28 8 6 42 3 2 2max彳I和:290 min彳丁邳:173max行:4 min行:2 交换这两行Option ExplicitPrivate Sub Command1_C1ick()Dim a(4,5),i As I nteger,j As I ntegerDim b(4)As I nteger,max As I nteger,min As I nteger Dim n As I nteger,m As I nteger,t As I nteger R

33、andomize max=0:min=327 67 For i=1 To 4For j=1 To 5 a(i,j)=I nt(90*Rnd)+10 Textl=Textl&Str(a(i,j)b(i)=b(i)+a(i,j)Next j Textl=Textl&vbCrLf I f max b(i)Then min=b(i):n=i End I f Next iLabel 1.Caption=max 行和:&max&min 行和:&min&vbCrLf&max行:&m&min行:&n&交换这两行“For j=1 To 5 t=a(m,j)a(m,j)=a(n,j)a(n,j)=t Next j

34、 For i=1 To 4 For j=1 To 5 Text2=Text2&Str(a(i,j)Next j Text2=Text2&vbCrLfNext i End Sub6-12Option ExplicitPrivate Sub Commandl_Click()Dim a(),i As I nteger,j As I ntegerDim b(4)As I nteger,max As I nteger,min As I ntegerDim n As I nteger,m As I nteger,t As I nteger Randomizen=I nputBox(矩阵阶数 n:)ReDi

35、m a(n,n)For i=1 To nFor j=1 To na(i,j)=I nt(90*Rnd)+10Textl=Textl&Str(a(i,j)Next jTextl=Textl&vbCrLfNext iFor i=1 To nFor j=1 To nText2=Text2&Str(a(j,i)Next jText2=Text2&vbCrLfNext iEnd SubPrivate Sub Command2_Click()Textl=Text2=End SubPrivate Sub Command3_Click()EndEnd Sub6-13Option ExplicitOption

36、Base 1Private Sub Commandl_Click()Dim a(3,3)As I nteger,i As I nteger,j As I ntegerDim max As Long,k As Long,f As I ntegerDim n As I nteger,m As I ntegerRandomizeFor i=1 To 3For j=1 To 3a(i,j)=I nt(90*Rnd)+10Textl=Textl&Str(a(i,j)Next jTextl=Textl&vbCrLfNext iFor i=1 To 3 主对角线方向 m=i k=1For j=1 To 3

37、k=k*a(m,j)m=m+1 I f m 3 Then m=1 Next j I f k max Then max=k n=i f=1 End I f Next iFor i=1 To 3 辅对角线方向m=i k=1For j=1 To 3 k=k*a(j,m)m=m-1 I f m max Then max=k n=i f=2 End I f Next i Picturel.Print”最大组元素:”I f f=1 ThenFor i=1 To 2 Picturel.Print a(;n;i;a(n,i);n=n+1 I f n 3 Then n=1 Next i Picturel.Pri

38、nt a(;n;i;a(n,i)Elself f=2 ThenFor i=1 To 2 Picturel.Print a(;i;n;a(i,n);n=n-1 I f n 9k=k+1I f i+1 3 And j+1=3 Theni=1:j=j+1Elself i+1 3 Theni=i+1:j=1Elself i+1 3 And j+1 3 Theni=i-1Elself i+1=3 And j+1=3 And a(i+1,j+1)0 Then i=i-1Elsei=i+1:j=j+1End I fa(i,j)=kLoopFor i=1 To 3For j=1 To 3Picturel.Pr

39、int a(i,j);Next jPicturel.PrintNext iEnd SubPrivate Sub Command2_Click()Dim a()As I nteger,i As I nteger,j As I ntegerDim k As I ntegerDim n As I ntegern=I nputBox(幻方阶数:”)ReDim a(n,n)i=n:j=(n+1)/2:a(i,j)=1:k=1Do Unti1 k n*nk=k+1I f i+1 n And j+1=n Theni=1:j=j+1Elself i+1 n Theni=i+1:j=1Elself i+1 n

40、And j+1 n Then i=i-1Elself i+1=n And j+1=n And a(i+1,j+1)0 Then i=i-1Elsei=i+1:j=j+1 End I f a(i,j)=k Loop For i=1 To nFor j=1 To nPicturel.Print Right(?,&a(i,j),4);Next jPicturel.Print Next i End Sub6T5,副对角相加6-15 0回国2 5 2 89 7 3 65 6 6 29 5 8 89 9 7 88 6 158 8 2 85 2 5 6max.284a(1,3)=95a(2,2)=69a(3

41、,1)=52at 4,4)=68退出Option ExplicitOption Base 1Private Sub Commandl_Click()Dim a()As I nteger,i As I nteger,j As I ntegerDim max As Long,k As Long,f As I ntegerDim n As I nteger,m As I nteger Randomizef=I nputBox(输入方阵阶数:”)ReDim a(f,f)For i=1 To fFor j=1 To fa(i,j)=I nt(90*Rnd)+10Textl=Textl&Str(a(i,j

42、)Next jTextl=Textl&vbCrLfNext iFor i=1 To f 副对角线方向m=ik=0For j=1 To f k=k+a(j,m)m=m-1I f m max Then max=k n=iEnd I fNext iPicturel.Print max:maxFor i=1 To fPicturel.Print a(;i;n;a(i,n)n=n-1I f n l 13 回区Private Sub Command3_Click()End End SubPublic Function Prime(ByVai N As I nteger)As Dim k As I nteg

43、er For k=2 To Sqr(N)I f N Mod k=0 Then Exit Function Next k Prime=TrueEnd Function7.Private Sub Command1_Click()Dim ss As StringDim i As I ntegerFor i=1 To 100I f Prime(i)And Prime(i+2)Then ss=ss&Chr(13)&Chr(10)Str(i+2)End I fNext i Textl=ss End SubBooleanPublic Function Prime(ByVai N As I nteger)As

44、 Boolean Dim k As I ntegerFor k=2 To Sqr(N)I f N Mod k=0 Then Exit FunctionNext kPrime=TrueEnd Function8.Option Explicit Option Base 1 Private Sub Form_Click()Dim a As I nteger,n As I nteger Dim i As I nteger Randomize Dim aa(20)As I nteger a=I nt(100*Rnd()*1)n=1 Do For i=1 To n-1 I f a=aa(i)Then Ex

45、it For End I f Next i I f i=n Then aa(n)=a n=n+1 End I f a=I nt(100*Rnd()*1)Loop While n Max ThenMax=s maxi=i End I f Next i Print Str(a(maxi)&+&Str(a(maxi+1)&+&Str(a(maxi&Str(a(maxi+3)&=&Str(Max)End SubPrivate Sub Commandl_Click()Dim a(5,5)As I nteger Randomize For i=1 To 5 For j=1 To 5 a(i,j)=I nt

46、(100*Rnd)+Print a(i,j);Next j Print Next i Call fmax(a)End SubPrivate Sub fmax(a()As I nteger)Max=a(l,1)maxi=1 maxj=1 For i=1 To 5 For j=1 To 5 I f a(i,j)Max Then Max=a(i,j)maxi=i maxj=j End I f Next j Next iPrint”最大元素为:a(+Str(maxi)+:+Str(maxj)+)=+CStr(Max)11.A Forl 13回冈Private Sub Commandl_Click()1

47、1 1 2 3 5 8CommandlDim i As I ntegerFor i=1 To 6Textl=Textl&Str(fab(i)Next iEnd SubPrivate Function fab(n As I nteger)As LongI f n=1 Or n=2 Then fab=1Elsefab=fab(n-1)+fab(n-2)End I fEnd Function12.Private Sub Command1_Click()Dim i As I ntegera=I nputBox(请输入一个大于2的偶数:)n=Vai(a)I f n=4 ThenPrint 4=2+2Ex

48、it SubEnd I fFor i=3 To n-1 Step 2I f prime(i)And prime(n-i)ThenPrint Str(n)+“=+Str(i)Exit SubEnd I fStr(n-i)78=5+73+Next i Print End Sub歌德巴赫猜想不对!CommandlPrivateFor iFunction prime(ByVai n AsI nteger)As Boolean=2 To nI f n Mod i=-10 Thenprime=FalseExit Function End I fNext i prime=True End Function1

49、3.Private Sub Command1_C1ick()Dim i As I ntegerFor i=10 To 9999Cal 1 arm(i)153370371407163482089474CommandlNext iEnd SubPrivate Sub arm(j As I nteger)a=CStr(j)n=Len(a)For k=1 To nb=Mid(a,k,1)s=s+Vai(b)-n Next kI f s=j Then Print jEnd I fEnd Sub14.Private Sub Command1_Click()Dim n As I nteger,m As St

50、ring,b As I ntegern=I nputBoxC请输入原始数的进制(2T6):”)m=I nputBox(请输入原始数:)Label 1.Caption=Str(n)+进制数”Textl=m b=trans(m,n)Text2=Str(b)End SubPrivate Function trans(m As String,n As I nteger)As I nteger Dim k As I nteger,t As String,r As I nteger,s As I nteger k=Len(m)t=UCase(Mid(m,i,1)I f t=A And t Max Then

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 通信科技 > 开发语言

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服