欢迎来到天天文库
浏览记录
ID:40572400
大小:72.50 KB
页数:10页
时间:2019-08-04
《vb源程序代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Vb源代码(周至县第五中学710402数学组唐永鸽)1PrivateSubForm_Click()DimnAsInteger,f1AsDouble,f2AsDouble,f3AsDoubleDimiAsIntegern=Val(InputBox("输入要输出的项数:","输出斐波那契数列",20))f1=0f2=1PrintTab(8);f1PrintTab(8);f2Fori=3Tonf3=f2+f1PrintTab(8);f3f1=f2f2=f3NextEndSub2PrivateSubForm_Click()Dim
2、nAsInteger,f1AsDoublen=1Forn=1To66f1=15*nPrintf1NextEndSub3PrivateSubForm_Click()Dima1AsDouble,nAsDouble,iAsIntegera1=Val(InputBox("请输入第1个数","找最大数"))PrintTab(5);a1Fori=2To5n=Val(InputBox("请输入第"&i&"个数"))PrintTab(5);nIfn>a1Thena1=nNextPrint""Print"最大数为";a1EndSub4、P
3、rivateSubForm_Click()DimyearAsLong10year=InputBox("请输入年份")IfyearMod4=0ThenIfyearMod100=0ThenIfyearMod400=0ThenPrintyear;"年是闰年"ElsePrintyear;"不年是闰年"EndIfElsePrintyear;"年是闰年"EndIfElsePrintyear;"不年是闰年"EndIfEndSub5、PrivateSubform_Click()DimyearAsLongForyear=2000To250
4、0IfyearMod4=0ThenIfyearMod100=0ThenIfyearMod400=0ThenPrintyear;"年是闰年",ElsePrintyear;"年不是闰年",EndIfElsePrintyear;"年是闰年",EndIfElsePrintyear;"年不是闰年",EndIfNextEndSub6、OptionBase1PrivateSubForm_Click()Constn=10Dima(n)AsSingleMax=0k=010Fori=1Tona(i)=Val(InputBox("请输入第"&
5、i&"个数","找最大数"))PrintTab(5);"第"&i&"个数为:";a(i)NextiFori=1TonIfMax6、2^3+f3^3=nThenPrintn;"为水仙花数"EndIfNextEndSub方法2、PrivateSubForm_Click()DimnAsInteger,f1AsInteger,f2AsInteger,f3AsIntegern=100DoWhilen<=999f1=Int(n/100)f2=Int(n/10)Mod10f3=nMod10Iff1^3+f2^3+f3^3=nThenPrintn;"为水仙花数"EndIfn=n+1LoopEndSub8、PrivateSubForm_Click()DimnAsIn7、teger,sAsIntegern=1s=010Dos=s+nn=n+1LoopWhiles<=200n=n-2PrintnEndSub9、二分法方法1、PublicFunctionf(xAsDouble)AsDoublef=x^3-x-1EndFunctionPrivateSubcommand1_Click()DimaAsDouble,bAsDouble,pAsSinglea=1b=1.5p=0.00001DoIff((a+b)/2)=0ThenExitDoElseIff(a)*f((a+b)/2)<0Thenb=(a8、+b)/2Elsea=(a+b)/2EndIfEndIfLoopWhileb-a>=pLabel1.Caption="方程的根是"&(a+b)/2EndSubPrivateSubCommand2_Click()Label2.Caption="求方程f=x^3-x-1的近似解"EndSub方法2、PrivateSubC
6、2^3+f3^3=nThenPrintn;"为水仙花数"EndIfNextEndSub方法2、PrivateSubForm_Click()DimnAsInteger,f1AsInteger,f2AsInteger,f3AsIntegern=100DoWhilen<=999f1=Int(n/100)f2=Int(n/10)Mod10f3=nMod10Iff1^3+f2^3+f3^3=nThenPrintn;"为水仙花数"EndIfn=n+1LoopEndSub8、PrivateSubForm_Click()DimnAsIn
7、teger,sAsIntegern=1s=010Dos=s+nn=n+1LoopWhiles<=200n=n-2PrintnEndSub9、二分法方法1、PublicFunctionf(xAsDouble)AsDoublef=x^3-x-1EndFunctionPrivateSubcommand1_Click()DimaAsDouble,bAsDouble,pAsSinglea=1b=1.5p=0.00001DoIff((a+b)/2)=0ThenExitDoElseIff(a)*f((a+b)/2)<0Thenb=(a
8、+b)/2Elsea=(a+b)/2EndIfEndIfLoopWhileb-a>=pLabel1.Caption="方程的根是"&(a+b)/2EndSubPrivateSubCommand2_Click()Label2.Caption="求方程f=x^3-x-1的近似解"EndSub方法2、PrivateSubC
此文档下载收益归作者所有