VFP程序设计(要详细具体)大神求教!

VFP程序设计(要详细具体)大神求教!
程序部分:
1.某一范围内能被某数或另一数整除的数的个数;
2.计算某范围内能被一个数整除所有数的和,并写出结果;
3.写程序求出某范围内能被一数和另一数整除的和;
4.已知一数例求前20项的和;
5.求出某一数的真因子中最大的;
流星kk 1年前 已收到1个回答 举报

清风朝露 幼苗

共回答了21个问题采纳率:90.5% 举报

input "输入开始数" to sinput "输入结束数" to einput "输入除数" to dn=0

for i=s to e if i % d=0 n=n+1 endifendfor? ninput "输入开始数" to sinput "输入结束数" to einput "输入除数" to ds=0for i=s to e
if i % d=0 s=s+i endifendfor? sinput "输入开始数" to sinput "输入结束数" to einput "输入第一个除数" to d1input "输入第二个除数" to d2
s=0for i=s to e
if (i % d1=0 ) and (i % d2=0 ) s=s+i endifendfor? sdime A(100)input "数列中数的个数" to nfor i=1 to n input to a(i)endfors=0for i=1 to 20 s=s+a(i)endfor? "前20项的和="? s这题有不同的理解,理解为能够整除该数的不等于该数的最大整数,程序如下:input "给出一个整数" to nfor i=n-1 to 1 step -1 if n % i=0 exit endifendfor? i如果理解为先把n分解为质因数,再求作为底的最大质数,则程序更复杂一些,可为:
input "给出一个整数" to nmax=1
for i=2 to sqrt(n) if n % i=0 n=n/i if i>max max=i endif endifendforif max=1 ? nelse ? maxendif

1年前

6
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 1.422 s. - webmaster@yulucn.com