bshy.net
当前位置:首页>>关于vb程序. 求1~100之间能够被5整除的所有整数个数....的资料>>

vb程序. 求1~100之间能够被5整除的所有整数个数....

dim i as integer ,sum as long for i=1 to 100 if i mod 5=0 then sum=sum+1 next msgbox sum

dim i as integer dim sum as integer sum=0 for i=100 to 200 step 5 if i mod 30 then sum=sum+i next

Private Sub Command1_Click() y = 1 For i = 20 To 30 Step 5 y = y * i Next i Print yEnd Sub

Private Sub Form_Click() Dim i As Long, A As Long A = 0 For i = 1 To 200 If i Mod 5 = 0 And i Mod 7 = 0 Then Print i A = A + i End If Next Print "以上是同时被5和7整除的数,和=" & A End Sub

dim n as integer dim k as integer dim i as integer n=val(inputbox("输入一个正整数n:")) k=0 for i = 1 to n if i mod 5 = 0 then k = k + 1 next i print k

小于1000不包括1000 5和7的最小公倍数是35,就是找到1000以下的不能被5整除,不能被7整除的数. 能被5整除:(1000÷5-1)=199 能被7整除:(1001÷7-1)=142 重复计算的:999÷35=28. 小于1000能被5整除,或能被7整除的正整数的个数为:199+142-28=303...

被5整除的数有一个特点,分为两类,一类是可以被10整除,如10,20……,另一类就是不能被10整除但是能被5整除,如5,15…… dim count1 as long ‘先看n整除以10等于多少,比如n是10的话,那么为1,但是有两个数能被5整除,20同理。 count1=(n \10)*2 if...

dim i as integer dim n as integer n = 0 for i=1 to 100 if i mod 7 = 0 then print i, n = n + 1 if n mod 5 = 0 then Print end if next i

Private Sub Command1_Click() For i = 5 To 200 Step 5 Print i; If i Mod 50 = 0 Then Print Next End Sub

Private Sub Command1_Click()Text1.Text = ""Dim AA(1 To 20) As Integer, SS As Integer, SDA As IntegerFor I = 1 To 20RandomizeAA(I) = Int(Rnd * 99 + 1)Next IFor I = 1 To 19 For J = 1 To 20 - I If AA(J) > AA(J + 1) Then SDA = AA(...

网站首页 | 网站地图
All rights reserved Powered by www.bshy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com