欢迎来到天天文库
浏览记录
ID:18815885
大小:53.00 KB
页数:28页
时间:2018-09-25
《vb期末范围题总汇》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、VB期末范围题总汇《》1.求随机10个整数的最大值、最小值、平均值以及和;Dima(1To10)PrivateSubCommand1_Click()RandomizePicture1.Print"产生的随机数为:"Fori=1To10a(i)=Int(Rnd*99+1)Picture1.Printa(i);NextiPicture1.PrintEndSubPrivateSubCommand2_Click()Dimmax,min,avemax=a(1)min=a(1)ave=0.1*a(1)Fori=2
2、To10Ifa(i)>maxThenmax=a(i)Ifa(i)3、0*b+100*cThenMsgBox100*c+10*b+aEndIfNextcNextbNextaEndSub3.百元买百鸡问题;OptionExplicitConsta=5,b=3,c=1PrivateSubForm_Activate()DimiAsInteger,jAsInteger,kAsInteger,nAsIntegerFori=1To100Forj=1To100Fork=1To100Ifi*a+j*b+k*c=100Thenn=n+1List1.AddItem"公鸡:"&i&"母鸡:"4、&j&"小鸡:"&kEndIfNext:Next:NextMsgBox"共有组合:"&nEndSub求1000以内的所有完数一个按钮里调用的过程PrivateSubCommand1_Click()OutputWanNumber1000EndSub4.'求完数的过程PrivateSubForm_Click()Dimi,jAsIntegerFori=4To100temp=1Forj=2Toi/2IfiModj=0Thentemp=temp+jEndIfNextjIftemp=iThenPrintiEndI5、fNextiEndSub5.求各位数字之和inputa:'输入任意数dob=amod10:'取a的末位数sum=sum+b:'求和a=a10:'去掉末位数loopuntila=0print"sum=";sum:'输出end(dimnasstringinputnfori=1tolen(n)sum=sum+val(mid(n,i,1))nextiprintsum)6.求最小公倍数PrivateSubForm_Load()Form1.AutoRedraw=TrueDimn1%,m1%,m%,n%,r%n16、=InputBox("输入n1")m1=InputBox("输入m1")Ifm1>n1Then'为了求最小公倍数,增加m,n变量m=m1:n=n1Elsem=n1:n=m1EndIfDor=mModnIfr=0ThenExitDom=nn=rLoopPrintn1;",";m1;"的最大公约数为";nPrint"最小公倍数=",m1*n1/nEndSub7.求逆序数(感觉题目类型太多)8.级数有限项求和问题(题目类型太多)9.求质因子问题PrivateSubCommand1_Click()DimNAs7、Integer,IAsIntegerN=Val(InputBox("请输入2的整数:"))I=2DoIfNModI=0ThenPrintI;N=NIElseI=I1EndIfLoopWhileN1EndSub10.字符统计OptionBase1OptionExplicitPrivateSubCommand1_Click()Dimiasinteger,A(26)asinteger,nasintegerDimSasstring*1,StrlasstringStrl=Text1n=Len(Strl)For8、i=1TonS=Mid(Strl,i,1)IfUCase(S)>=”A”AndUCase(S)<=”Z”ThenA(Asc(UCase(S))-64)+1EndIfNextiFori=1To26List1.AdditemChr(64+i)&“:”&A(i)NetxiEndSubPrivateSubCommand_Click()EndEndSub第二大题1.判定素数过程Functionisprime(NumAsLong)AsBooleanIfNum<2Th
3、0*b+100*cThenMsgBox100*c+10*b+aEndIfNextcNextbNextaEndSub3.百元买百鸡问题;OptionExplicitConsta=5,b=3,c=1PrivateSubForm_Activate()DimiAsInteger,jAsInteger,kAsInteger,nAsIntegerFori=1To100Forj=1To100Fork=1To100Ifi*a+j*b+k*c=100Thenn=n+1List1.AddItem"公鸡:"&i&"母鸡:"
4、&j&"小鸡:"&kEndIfNext:Next:NextMsgBox"共有组合:"&nEndSub求1000以内的所有完数一个按钮里调用的过程PrivateSubCommand1_Click()OutputWanNumber1000EndSub4.'求完数的过程PrivateSubForm_Click()Dimi,jAsIntegerFori=4To100temp=1Forj=2Toi/2IfiModj=0Thentemp=temp+jEndIfNextjIftemp=iThenPrintiEndI
5、fNextiEndSub5.求各位数字之和inputa:'输入任意数dob=amod10:'取a的末位数sum=sum+b:'求和a=a10:'去掉末位数loopuntila=0print"sum=";sum:'输出end(dimnasstringinputnfori=1tolen(n)sum=sum+val(mid(n,i,1))nextiprintsum)6.求最小公倍数PrivateSubForm_Load()Form1.AutoRedraw=TrueDimn1%,m1%,m%,n%,r%n1
6、=InputBox("输入n1")m1=InputBox("输入m1")Ifm1>n1Then'为了求最小公倍数,增加m,n变量m=m1:n=n1Elsem=n1:n=m1EndIfDor=mModnIfr=0ThenExitDom=nn=rLoopPrintn1;",";m1;"的最大公约数为";nPrint"最小公倍数=",m1*n1/nEndSub7.求逆序数(感觉题目类型太多)8.级数有限项求和问题(题目类型太多)9.求质因子问题PrivateSubCommand1_Click()DimNAs
7、Integer,IAsIntegerN=Val(InputBox("请输入2的整数:"))I=2DoIfNModI=0ThenPrintI;N=NIElseI=I1EndIfLoopWhileN1EndSub10.字符统计OptionBase1OptionExplicitPrivateSubCommand1_Click()Dimiasinteger,A(26)asinteger,nasintegerDimSasstring*1,StrlasstringStrl=Text1n=Len(Strl)For
8、i=1TonS=Mid(Strl,i,1)IfUCase(S)>=”A”AndUCase(S)<=”Z”ThenA(Asc(UCase(S))-64)+1EndIfNextiFori=1To26List1.AdditemChr(64+i)&“:”&A(i)NetxiEndSubPrivateSubCommand_Click()EndEndSub第二大题1.判定素数过程Functionisprime(NumAsLong)AsBooleanIfNum<2Th
此文档下载收益归作者所有