vb 求100和200之间的偶数和
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/10 14:22:05
求奇偶数:Fori=1to100Ifi/2i\2Thenmsg=msg&i&"是奇数"Elsemsg=msg&i&"是偶数"NextiPrintmsg能被3和5同时整除:Fori=1to100Ifi/
PrivateSubfun()ifimod2=0thenforx=itoastep2s=s*xnextxelseforx=(i+1)toastep2thens=s*xnextxendif试试看行不行吧
DimiAsLongDimjAsLongDimkAsLongFori=0To100IfiMod2=0Thenj=j+iElsek=k+iNextMsgBox"偶数和:"&j&vbCrLf&"奇数和:"
语句自己找给思路.第一种:暴力运算1.申请2个变量jsum,osum分别放奇数和、偶数和.赋初值0.2.做个循环从1到100,变量用i2.1判断i是否为奇数,是的话jsum=jsum+i,否则osum
DimiasInteger,jasInteger,oasIntegerj=0o=0Fori=1To100Step2j=j+io=o+(i+1)NextDebug.print"100以内的奇数和:"&j
PrivateSubCommand1_Click()RandomizeTimerFori=1To100x=Int(Rnd()*90+10)IfxMod2=0Thenm=m+xElsen=n+xEndI
#includevoidmain(){\x09//c语言编程计算1到200之间的奇数和与偶数和\x09inta,sum1=0,sum2=0;\x09for(a=1;a
1.DimnAsInteger,iAsIntegerDimjiAsDoublen=Val(Text1.Text)i=1ji=1Doji=ji*ii=i+1Ifi>nThenExitDoLoopPrin
PrivateSubCommand1_Click()Dimi,sum1,sum2AsIntegersum1=0sum2=0Fori=1To100IfiMod2=1Thensum1=sum1+iElse
privatesubcommand1_click()dima(9),b(),c,d,e,iasintegerfori=0to9a(i)=int(val(inputbox("输入第"&i+1&"个数:"
PrivateSubCommand1_Click()Fori=0ToList1.ListCount-1j=j+1Ifj=11ThenExitForIfList1.List(i)NextEndSubPr
248050247500再问:不是说结果的,而是说编程的再答:我不懂vb,只会用php或者其他的,简单的用basic写一下吧,大致思路是这样的。sum1=0sum2=0fora=100to10000i
在窗口上建立一个按钮:FunctionTotal(Num1,Num2)AsString'Num1为奇数和'Num2为偶数和Fori=1To100IfiMod20ThenNum1=Num1+iElseN
PrivateSubCommand1_Click()Fori=100To999IfIsPrime(i)Thenn=n+1Printi;IfnMod10=0ThenPrintEndIfNextiEndS
10+11+12+13+14+.+99+100=(10+100)x91/2=5005
Functiona(n)DimmAsLongm=n\2a=m*(m+1)EndFunction
PrivateSubCommand1_Click()Dimsum,iAsIntegersum=0Fori=0To200-1IfiMod2=0Thensum=sum+iNextiPrintsumEndS
PrivateSubCommand1_Click()DimArr(9)AsLong'用于存放产生的10随机数DimiAsLongDimnMaxAsLong'用于存放最大的偶数DimnMinAsLong
可设最小的整数为x,则三个整数依次为:x,x+2,x+4由题意的:100
PrivateSubForm_Click()Dima(30)AsIntegerDimiAsIntegerRandomizeFori=1To30a(i)=Int(100*Rnd)NextiFori=1T