湖南省计算机二级程序题库,湖南省计算机二级VF程序设计题库及答案50题.doc

VF程序设计题库及答案

1编程序求出1-200以内的能被7整除的数的平方和。377986

clea

s=0

m=0

for i=1 to 200

if i%7=0

m=i^2

s=s+m

endif

endfor

?s

2编程序求1~99的平方根的和并输出结果。(保留小数点两位)661.46

clea

s=0

for i=1 to 99

s=s+sqrt(i) 中间三步的顺序不可以更改

endfor

?round(s,2) 保留小数点位数设置,系统默认也为两位

4编程序统计1~1000能被3整除的数的个数。 333

clea

s=0

for n=1 to 1000

if n%3=0

s=s+1

endif

endfor

?s

6编程序求出1~200所有整数的平方和并输出结果。2686700

clea

s=0

for n=1 to 200

s=s+n^2

endfor

?s

7编程序求出1到5000之间的能被5整除的前若干个偶数之和,当和大于500时程序退出。550

Clea clear

s=0 s=0

for n=10 to 5000 step 10 for n=1 to 5000

s=s+n if n%10=0

if s>500 s=s+n

exit endif

endif if s>500

endfor exit

?s endif

?s

8 编程序求在3000以内被17或者23整除的正整数数的个数。 299

clea

s=0

for n=1 to 3000

if n%17=0 or n%23=0

s=s+1 求个数

endif

endfor

?s

11编程序求出1-100以内的能被3整除的数的平方和。112761

clea

s=0

for n=1 to 100

if n%3=0

s=s+n^2

endif

endfor

?s

12已知一个数列的前3个数为0,0,1,以后每个数为前3个数的和,编程序求此数列的第36个数。334745777

clea

dimef(36)

f(1)=0

f(2)=0

f(3)=1

s=0

for n=4 to 36

f(n)=f(n-3)+f(n-2)+f(n-1)

s=f(n)

endfor

?s

13编程序求出1-100以内的能被9整除的数的平方和。40986

clea

s=0

for n=1 to 100

if n%9=0

s=s+n^2

endif

endfor

?s

14编程序求出1-200以内的能被3整除的数的平方和。882189

clea

s=0

for n=1 to 200

if n%3=0

s=s+n^2

endif

endfor

?s

15编程序求出1-7000以内能被3或者7整除数的个数。3000

clea

s=0

for n=1 to 7000

if n%3=0 or n%7=0

s=s+1

endif

endfor

?s

19 编程序求出1-4000以内能被3或者11整除数的个数。 1575

clea

s=0

for n=1 to 4000

if n%3=0 or n%11=0

s=s+1

endif

endfor

?s

20编程序求出1-5000以内能被37整除的整数之和。339660

clea

s=0

for n=1 to 5000

if n%37=0

s=s+n

endif

endfor

?s

24编程序求出100到200之间同时满足除3余2和除5余3条件的数的个数。6

clea

s=0

for n=100 to 200

if n%3=2 and n%5=3

s=s+1

endif

endfor

?s

30 1编程序求出 2+4+8+16+32+…这样的数之和。如果累加数大于500时,则程序终止并输出结果。510

clea

s=0

for n=1 to 100

s=s+2^n

if s>500

exit

endif

endfor

?s

31 编程序求出1~100所有整数的立方和并输出结果。25502500

clea

s=0

for n=1 to 100

s=s+n^3

endfor

?s

39 编写程序,计算1000以内有多少个这样的数,该数既能被6整除又能被8整除。41

clea

s=0

for n=1 to 1000

if n%6=0 and n%8=0

s=s+1

endif

endfor

?s

50 编程序求出1到5000之间的能被7整除的前若干个数之和,当和大于1500时退出并输出结果。1617

clea

s=0

for n=1 to 5000

if n%7=0

s=s+n

endif

if s>1500 分写两次 if

exit

endif

endfor

?s

4

展开阅读全文

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值