湖南省VFP编程求取(2012-11-24).docVIP

  • 15
  • 0
  • 约3.45万字
  • 约 14页
  • 2017-09-11 发布于四川
  • 举报
湖南省VFP编程求取(2012-11-24)

一、编程求取:[121,200] 之间的弦数的之和。(若某正整数的平方等于另两个正整数平方之和,则称该数为弦数. 例如:3^2+4^2=5^2, 因此5是弦数)。2set talk offClea n=0 for a=121 to 200 for x=1 to a t=a-x if int(sqrt(t))*int(sqrt(t))=t*t n=n+1 exit endif endfor endfor ? n set talk on return 6504 2、编程求取:[121,200] 之间的第10个弦数。(若某正整数的平方等于另两个正整数平方之和,则称该数为弦数. 例如:3^2+4^2=5^2, 因此5是弦数)。2set talk offClea n=1 for a=121 to 200 for x=1 to a-1 t=a*a+x*x if int(sqrt(t))*int(sqrt(t))=t n=n+1 if n=10 ? a Return Endif Exit Endif Endfor Endfor set talk on return145 3、勾股弦数是满足公式: A^2+B^2=C^2 (假定ABC)的一组正整数(A,B,C),例如,(3,4,5)是勾股弦数,因为:3^2+4^2=5^2。求A,B均小于25且A+B+C=100的勾股弦数的个数。2set talk offclean=0 for a=1 to 25 for b=1 to 25 for c=1 to 100 if ab and bc if a+b+c=100 n=n+1 endif endif endfor endfor endfor ? n return11 4、勾股弦数是满足公式: A^2+B^2=C^2 (假定ABC)的一组正整数(A,B,C),例如,(3,4,5)是勾股弦数,因为:3^2+4^2=5^2。求[1,60]中的勾股弦数的个数。2set talk offclea n=0 for a=1 to 60 for b=1 to 60 for c=1 to 60 if ab and bc if a*a+b*b=c n=n+1 endif endif endfor endfor endfor ? n return26 5、勾股弦数是满足公式: A^2+B^2=C^2 (假定ABC)的一组正整数(A,B,C),例如,(3,4,5)是勾股弦数,因为:3^2+4^2=5^2。求[1,50]中使A+B+C取最大值的勾股弦数,并输出此最大值。2set talk offcleamax=1000for a=1 to 50for b=1 to 50for c=1 to 50if ab and bc if maxa+b+cmax=max+a+b+cendifendifendforendforendfor? maxreturn120 6、编写程序,求所有符合算式ij*ji=1300的最小数ij(即i*10+j)。其中i、j是1~9之间的一位整数。2set talk offcleamin=0for i=1 to 9for j=1 to 9if ij+ji=1300if minijmin=10*i+jendifendif endforendfor? minreturn25 编写程序,求所有符合算式ij*ji=1300的最大数ij(即i*10+j)。其中i、j是1~9之间的一位整数。2set talk offcleamax=110for i=1 to 9for j=1 to 9if ij+ji=1300if maxijmax=10*i+jendifendif endforendfor? maxreturn52 编写程序,求所有符合算式ij*ji=1300的最大数ij(即i*10+j)。其中i、j是1~9之间的一位整数。2set talk offcleamax=110for i=1 to 9for j=1 to 9if ij+ji=1300if maxijmax=10*i+jendifendif endforendfor? maxreturn27 若一个四位正整数是另一个正整数的平方,且各位数字的和是一个平方数,则称该四位正整数是四位双平方数。例如: 由于7396=86^2,且7+3+9+6=25=5^2,则称7396是四位双平方数。求所有四位双平方数中最小的一个四位双平方数。2set talk offcleamin=10000for i=1000 to 9999a=int(i/1000)b=int((i-a*1000)/100)c=mod(i,100)d=mod(i,10)x=a+b+c+dif sqrt(i))*int(sqrt(i)=i if minim

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档