vb求60以内勾股数个数
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/10 18:45:21
privatesubform_click()dimnasinteger,iasintegerfori=7to1000ifimod7=0thenn=n+1nextprintnendsu
Dimn,x,r,sAsSinglen=2s=0DoWhilen再问:能说一下算法的思路吗?再答:首先1不是素数,就用枚举将2到1000的每个数列举出来,再逐个检验,即从2到n/2一一举例,判断是否能
PrivateSubCommand1_Click()DimaAsIntegerDimbAsIntegerDimcAsIntegerDimiAsInteger,jAsIntegera=Text1b=Te
OptionExplicitOptionBase1PrivateSubForm_Click()Dimi%,j%,k%,n%Dima()AsIntegern=0Fori=1To1000k=0Forj=1
首先2,4位没1位又不算所以只要搜索3位就可以了beginfori:=100to999doif(imod10)=(idiv100)then{判断回文数}begin{判断素数}j:=3;repeatt:
count=0Fori=1To1000IFi%7==0Thencount++Nexti
DimiAsLongDimCountAsLongFori=1To100If(iMod3=0)And(iMod2=0)ThenCount=Count+1Debug.PrintiEndIfNextMsgB
PrivateSubCommand1_Click()fori=1to20a=val(inputbox("输入第"&i&"个数:"))ifa>=0thenj=j+1:s=s+anextprint"正数个
PrivateSubForm_load()DimiAsIntegerDimjAsIntegerDimxAsIntegerFori=2To10000f=0'f用来标识是否为素数Forj=2ToInt(S
程序的思路有问题.PrivateSubCommand1_Click()n=2'素数从2开始s=0'素数和DoWhilen
PrivateSubCommand1_Click()Fori=1To100Forj=1ToiFork=1TojIfi^2=j^2+k^2ThenPrinti;j;kNextkNextjNextiEnd
帮你做好了附件,你自己研究一下吧,Private Sub Command1_Click() '奇数算术平方根之和 &
privatesubcommand1_click()dima(9),b(),c,d,e,iasintegerfori=0to9a(i)=int(val(inputbox("输入第"&i+1&"个数:"
OptionExplicitPrivateSubForm_Click()Form1.AutoRedraw=TrueClsDimAAsInteger,SuAsBoolean,IAsInteger,JAs
PrivateSubCommand1_Click()Fori=2000To9999IfTrim(Str(i))=Trim(StrReverse(Str(i)))ThenPrintStr(i)EndIf
Functioncalc()dimaasintegerdimbaslongfora=0to100step2b=b+a^2nextacalc=bendfunction这个算法比你的优化一些,如果你想用自
PrivateSubCommand1_Click()Dimsum,iAsIntegersum=0Fori=0To200-1IfiMod2=0Thensum=sum+iNextiPrintsumEndS
Dima%,b%,c%,s1,s2,sPrivateSubForm_Click()Fori=1To1000IfiMod7=0Thena=a+1s1=s1+iEndIfIfiMod17=0Thenb=b
先写两个数列.PublicSubaa()DimabAsStringDimi,jAsIntegerDima,bAsInteger'素数序列Fori=1To1000Forj=1ToiIfiModj=0An
PrivateSubCommand1_Click()Sum=0Fori=0To9Print10*i+7;Sum=Sum+10*i+7NextiPrintPrint"Sum=";SumEndSu