VB计算1*2*3 2*3*4
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 09:50:34
PrivateSubCommand1_Click()DimnAsInteger,tmpAsDouble,sumAsDoubleDimiAsInteger,jAsIntegern=4tmp=1Fori=
数学计算可以简化过程:因为1-2=-1,3-4=-1...所以得出-1+(-1)+...,重复(100/2)次,即代码为(这是最简单而且最快速的办法):DimsAsInteger=-(100/2)如果
PrivateSubCommand1_Click()DimnAsLong,xAsSingle,yAsSingle,y2AsSingle,sumAsSinglex=Val(InputBox("请输入一个
你给的公式不对!应该是π/2=2^2/1*3×4^2/3*5×.×(这个公式求的精度不高!代码如下:DimPI1AsDoubleDimPI2AsDoubleDimTempAsDoubleDimnAsD
这样的题目主要是利用Mod运算,能被13整除,n就加1,代码如下:PrivateSubCommand1_Click()Fori=1To9999IfiMod13=0Thenn=n+1EndIfNexti
阶乘n!=n*(n-1)(n-2)(n-2)···3*2*1
PrivateSubCommand1_Click()DimsAsString,nAsInteger,iAsIntegerFori=1To100n=n+iNextiPrint"1+2+3+……+100=
PrivateSubCommand1_Click()DimSAsDouble,jcAsDouble,NAsIntegerjc=1N=Val(InputBox("请输入N"))Fori=1ToNjc=j
看了上面几位的代码:应该都写错了楼主的问题是:s等于1到N之间每个整数的阶乘相加,而不是N的阶乘我没理解错吧?稍等完毕:在模块中输入代码:PublicFunctionfac(nAsInteger)As
PrivateSubCommand1_Click()DimiAsDoubleDimnAsDoubleDimsumAsDoublesum=0IfNotIsNumeric(Text1.Text)Then'
PrivateSubfounction()DimiAsIntegerDimjAsIntegerDimkAsLongDimResAsDoubleRes=1Fori=1To10k=1Forj=iTo1St
你好!PrivateSubForm_Click()DimiAsIntegerDimsAsIntegerFori=1To100s=s+iNextiPrintsEndSu
s=1fori=1to10s=s*inextmsgboxs
PrivateSubCommand1_Click()DimnAsInteger,iAsInteger,jAsInteger,Sum&,m&n=Val(InputBox("请输入N值"))Sum=0Fo
PrivateSubCommand2_Click()DimIAsLong,SAsLongForI=1To100IfIMod2=0ThenS=S-IElseS=S+IEndIfNextPrintSEnd
PrivateSubCommand1_Click()DimiAsInteger,sAsIntegers=0Fori=1To99s=s+i*(i+1)NextiDebug.Print"计算1*2+2*3
privatesubcommand1-click()dimn%,y#,s&n=2:y=0:s=1dos=s*ny=y+1/sn=n+1loopuntil1/s
PrivateSubCommand1_Click()Dimi,j,tDimsumsum=1Fori=2To10t=1Forj=1Toit=t*2Nextjsum=sum+tNextiPrintsumE
DimsumAsInteger,iAsIntegersum=0Fori=1To100sum=sum+iNextDebug.Print"1+2+...+100=";sum
PrivateSubCommand1_Click()DimnAsDoublen=Val(InputBox("N="))Fori=1Tons=s+1/(n*(n+1))NextiMsgBox"所求的和为