(50分,满意再加50)vb程序填空题!最好算出答案.大家帮帮忙吧..都是些题库里的题目,就要考试了阿~
1.统计[521,8421]之间有?个这样的整数,各位数字之和能被7整除PrivateSubForm_Click()DimcountAsIntegercount=0Fon...
1.统计[521,8421]之间有?个这样的整数,各位数字之和能被7整除
Private Sub Form_Click()
Dim count As Integer
count = 0
FontSize = 14: FontBold = True
For i = 521 To 8421
Select Case i
Case 521 To 999
a = i \ 100
b = i \ 10 Mod 10
c = i Mod 10
If (a + b + c) Mod 7 = 0 Then count = count + 1
Case ___
a = i \ 1000;b = i \ 100 Mod 10;c = i \ 10 Mod 10;d = i Mod 10
If (a + b + c + d) Mod 7 = 0 Then count = count + 1
End Select
Next I
Print count
End Sub
2.统计[521,8421]之间有多少个这样的整数,其各位数字之积能被7整除。
Private Sub Form_Click()
Dim count As Integer
count = 0
FontSize = 14: FontBold = True
For i = 521 To 8421
Select Case i
Case 521 To 999
a = i \ 100
b = i \ 10 Mod 10
c = i Mod 10
If (a * b * c) Mod 7 = 0 Then count = count + 1
Case ________________
a = i \ 1000
b = i \ 100 Mod 10
c = i \ 10 Mod 10
d = i Mod 10
If (a * b * c * d) Mod 7 = 0 Then count = count + 1
End Select
Next i
Print count
End Sub
3.我国古代数学家在《算经》中出了一道题:鸡翁一,值钱五;鸡母一,值钱三;鸡雏三,值钱一。百钱买百鸡,问鸡翁、母、雏各几何?”意为公鸡4吊钱1只,母鸡3吊钱1只,3只小鸡值1吊钱。编程实现用100吊钱买100只鸡,公鸡、母鸡、小鸡每种鸡至少一只,有多少种买法?
Private Sub command1_Click()
Dim a%, b%, c%, s%
FontSize = 14: FontBold = True
Print: Print: Print
s = 0
For a = 1 To 20
For b = 1 To 34
________________
If 4 * a + 3 * b + c / 3 = 100 Then s = s + 1
Next b
Next a
Print s
End Sub
4.要将一张100元的大钞票,换成等值的10元、5元、2元和1元一张的小钞票。
要求每次换成50张小钞票,每种至少一张。编程求有多少种换法。
Private Sub Command1_Click()
Dim i, j, k, m As Integer
Dim RMBsum As Integer
FontSize = 14: FontBold = True
For i = 1 To 9
For j = 1 To 17
For k = 1 To 37
m = 50 - i - j - k
If ________________ Then RMBsum = RMBsum + 1
Next k, j, i
Print RMBsum
End Sub
5.已知Sum= 1+1 / 1! + 1 / 2! + 1 / 3! + … + 1 / n! ,求当n为多少时,sum的值大于2.718281828?
Private Sub Command1_Click()
Dim i%, s#, sum#
i = 1
s = 1
sum = 1
Do
s = s * i
_______________________
If sum > 2.718281828 Then
Print i
Exit Do
End If
i = i + 1
Loop
End Sub
6.已知sum=1/(1*2)+1/(2*3)+…+1/(n*(n+1))的值,其中n为整数,计算n=25时sum的值。(要求结果保留到小数点后第五位)
Private Sub Form_Click()
Dim I%, sum#
I = 1
sum = 0
For I = 1 To 25
________________
Next
Print Format(sum, "0.#####")
End Sub
7.已知sum=4/3!+6/5!+…+(n+1)/n!,其中n为整数,计算n=15时sum的值。(要求结果保留到小数点后第九位)
Private Sub Command1_Click()
Dim i%, s#, sum#
sum = 0
n = 15
For i = 3 To n Step 2
_________________
For j=1 to i
s=s*j
Next j
sum = sum + (i + 1) / s
Next i
Print Format(sum, "0.#########")
End Sub
8.在[1,10000]范围内考察个位数字是1的素数个数
Private Sub Form_click()
For i = 2 To 10000
j = 2: k = Int(i / 2) + 1
Do While j <= k
If i Mod j = 0 Then Exit Do
j = j + 1
Loop
If j > k Then
m = Str(i)
______________
If mr = "1" Then s = s + 1
End If
Next i
Print s
End Sub
9.在[1,10000]范围内考察个位数字是3的素数的和?
Private Sub Form_click()
For i = 2 To 10000
j = 2: k = Int(i / 2) + 1
Do While j <= k
If i Mod j = 0 Then Exit Do
j = j + 1
Loop
If j > k Then
m = Str(i)
____________________
If mr = "3" Then s = s + i
End If
Next i
Print s
End Sub
10.以下程序的功能是求:在[200,999]范围内同时满足以下两个条件的十进制数的个数。⑴其个位数字与十位数字之积除以10所得的余数是百位数字;⑵该数是素数。
Private Sub Command1_Click()
n = 0
For i = 200 To 999
If prime(i) = True Then
g = i Mod 10
s = i \ 10 Mod 10
b = i \ 100
If ________________________ Then n = n + 1
End If
Next i
Print n
End Sub
Private Function prime(x) As Boolean
p = x \ 2
For i = 2 To p
If x Mod i = 0 Then
prime = False
Exit For
End If
Next i
If i > p Then prime = True
End Function 展开
Private Sub Form_Click()
Dim count As Integer
count = 0
FontSize = 14: FontBold = True
For i = 521 To 8421
Select Case i
Case 521 To 999
a = i \ 100
b = i \ 10 Mod 10
c = i Mod 10
If (a + b + c) Mod 7 = 0 Then count = count + 1
Case ___
a = i \ 1000;b = i \ 100 Mod 10;c = i \ 10 Mod 10;d = i Mod 10
If (a + b + c + d) Mod 7 = 0 Then count = count + 1
End Select
Next I
Print count
End Sub
2.统计[521,8421]之间有多少个这样的整数,其各位数字之积能被7整除。
Private Sub Form_Click()
Dim count As Integer
count = 0
FontSize = 14: FontBold = True
For i = 521 To 8421
Select Case i
Case 521 To 999
a = i \ 100
b = i \ 10 Mod 10
c = i Mod 10
If (a * b * c) Mod 7 = 0 Then count = count + 1
Case ________________
a = i \ 1000
b = i \ 100 Mod 10
c = i \ 10 Mod 10
d = i Mod 10
If (a * b * c * d) Mod 7 = 0 Then count = count + 1
End Select
Next i
Print count
End Sub
3.我国古代数学家在《算经》中出了一道题:鸡翁一,值钱五;鸡母一,值钱三;鸡雏三,值钱一。百钱买百鸡,问鸡翁、母、雏各几何?”意为公鸡4吊钱1只,母鸡3吊钱1只,3只小鸡值1吊钱。编程实现用100吊钱买100只鸡,公鸡、母鸡、小鸡每种鸡至少一只,有多少种买法?
Private Sub command1_Click()
Dim a%, b%, c%, s%
FontSize = 14: FontBold = True
Print: Print: Print
s = 0
For a = 1 To 20
For b = 1 To 34
________________
If 4 * a + 3 * b + c / 3 = 100 Then s = s + 1
Next b
Next a
Print s
End Sub
4.要将一张100元的大钞票,换成等值的10元、5元、2元和1元一张的小钞票。
要求每次换成50张小钞票,每种至少一张。编程求有多少种换法。
Private Sub Command1_Click()
Dim i, j, k, m As Integer
Dim RMBsum As Integer
FontSize = 14: FontBold = True
For i = 1 To 9
For j = 1 To 17
For k = 1 To 37
m = 50 - i - j - k
If ________________ Then RMBsum = RMBsum + 1
Next k, j, i
Print RMBsum
End Sub
5.已知Sum= 1+1 / 1! + 1 / 2! + 1 / 3! + … + 1 / n! ,求当n为多少时,sum的值大于2.718281828?
Private Sub Command1_Click()
Dim i%, s#, sum#
i = 1
s = 1
sum = 1
Do
s = s * i
_______________________
If sum > 2.718281828 Then
Print i
Exit Do
End If
i = i + 1
Loop
End Sub
6.已知sum=1/(1*2)+1/(2*3)+…+1/(n*(n+1))的值,其中n为整数,计算n=25时sum的值。(要求结果保留到小数点后第五位)
Private Sub Form_Click()
Dim I%, sum#
I = 1
sum = 0
For I = 1 To 25
________________
Next
Print Format(sum, "0.#####")
End Sub
7.已知sum=4/3!+6/5!+…+(n+1)/n!,其中n为整数,计算n=15时sum的值。(要求结果保留到小数点后第九位)
Private Sub Command1_Click()
Dim i%, s#, sum#
sum = 0
n = 15
For i = 3 To n Step 2
_________________
For j=1 to i
s=s*j
Next j
sum = sum + (i + 1) / s
Next i
Print Format(sum, "0.#########")
End Sub
8.在[1,10000]范围内考察个位数字是1的素数个数
Private Sub Form_click()
For i = 2 To 10000
j = 2: k = Int(i / 2) + 1
Do While j <= k
If i Mod j = 0 Then Exit Do
j = j + 1
Loop
If j > k Then
m = Str(i)
______________
If mr = "1" Then s = s + 1
End If
Next i
Print s
End Sub
9.在[1,10000]范围内考察个位数字是3的素数的和?
Private Sub Form_click()
For i = 2 To 10000
j = 2: k = Int(i / 2) + 1
Do While j <= k
If i Mod j = 0 Then Exit Do
j = j + 1
Loop
If j > k Then
m = Str(i)
____________________
If mr = "3" Then s = s + i
End If
Next i
Print s
End Sub
10.以下程序的功能是求:在[200,999]范围内同时满足以下两个条件的十进制数的个数。⑴其个位数字与十位数字之积除以10所得的余数是百位数字;⑵该数是素数。
Private Sub Command1_Click()
n = 0
For i = 200 To 999
If prime(i) = True Then
g = i Mod 10
s = i \ 10 Mod 10
b = i \ 100
If ________________________ Then n = n + 1
End If
Next i
Print n
End Sub
Private Function prime(x) As Boolean
p = x \ 2
For i = 2 To p
If x Mod i = 0 Then
prime = False
Exit For
End If
Next i
If i > p Then prime = True
End Function 展开
2个回答
展开全部
'此答案经过VB程序测试验证:
1.1000 to 8421 '前面判断了3位数的数字,本空为判断4位数的数字
2.1000 to 8421 ‘同理1题
3.c=100-a-b ’本空满足第二个条件:鸡的个数之和为100只
4.i*10+j*5+k*2+m=100 ‘本空需满足钱的总和为100
5.sum=sum+1/s ’按所给公式求和
6.sum=sum+1/(i*(i+1)) ‘按所给公式求和
7.s=1 ’s必须初始化,否则默认为零将导致除数为零的错误
8.mr=right(m,1) ‘取右边的第一个字符串
9.mr=right(m,1) ‘取右边的第一个字符串
10.b=(g*s) mod 10 ’满足条件个位与数位之积于十的余数为百位数
’-------不懂得还可以问。给分吧!
1.1000 to 8421 '前面判断了3位数的数字,本空为判断4位数的数字
2.1000 to 8421 ‘同理1题
3.c=100-a-b ’本空满足第二个条件:鸡的个数之和为100只
4.i*10+j*5+k*2+m=100 ‘本空需满足钱的总和为100
5.sum=sum+1/s ’按所给公式求和
6.sum=sum+1/(i*(i+1)) ‘按所给公式求和
7.s=1 ’s必须初始化,否则默认为零将导致除数为零的错误
8.mr=right(m,1) ‘取右边的第一个字符串
9.mr=right(m,1) ‘取右边的第一个字符串
10.b=(g*s) mod 10 ’满足条件个位与数位之积于十的余数为百位数
’-------不懂得还可以问。给分吧!
展开全部
'此答案经过VB程序测试验证:
1.1000 to 8421 '前面判断了3位数的数字,本空为判断4位数的数字
2.1000 to 8421 ‘同理1题
3.c=100-a-b ’本空满足第二个条件:鸡的个数之和为100只
4.i*10+j*5+k*2+m=100 ‘本空需满足钱的总和为100
5.sum=sum+1/s ’按所给公式求和
6.sum=sum+1/(i*(i+1)) ‘按所给公式求和
7.s=1 ’s必须初始化,否则默认为零将导致除数为零的错误
8.mr=right(m,1) ‘取右边的第一个字符串
9.mr=right(m,1) ‘取右边的第一个字符串
10.b=(g*s) mod 10 ’满足条件个位与数位之积于十的余数为百位数
’-------不懂得还可以问。给分吧!
1.1000 to 8421 '前面判断了3位数的数字,本空为判断4位数的数字
2.1000 to 8421 ‘同理1题
3.c=100-a-b ’本空满足第二个条件:鸡的个数之和为100只
4.i*10+j*5+k*2+m=100 ‘本空需满足钱的总和为100
5.sum=sum+1/s ’按所给公式求和
6.sum=sum+1/(i*(i+1)) ‘按所给公式求和
7.s=1 ’s必须初始化,否则默认为零将导致除数为零的错误
8.mr=right(m,1) ‘取右边的第一个字符串
9.mr=right(m,1) ‘取右边的第一个字符串
10.b=(g*s) mod 10 ’满足条件个位与数位之积于十的余数为百位数
’-------不懂得还可以问。给分吧!
参考资料: VB程序测试验证
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询