本帖最后由 老刘1号 于 2017-3-16 20:09 编辑
回复 2# pcl_test
竟敢潜水!
这是笨算法:- '&@(cls&cscript -nologo -e:vbscript "%~0"&PAUSE&EXIT)
- num=0
- for i = 1 to 1000-1
- if i mod 3 = 0 or i mod 5 = 0 then
- num=num+i
- wscript.echo i
- end if
- next
- wscript.echo "总和:"&num
复制代码 较为机智的算法:- '&@(cls&cscript -nologo -e:vbscript "%~0"&PAUSE&EXIT)
- num=0
- num1=0
- num2=0
- do until num1 >= 1000-1
- num1=num1+3
- wscript.echo num1
- num=num+num1
- loop
- do until num2 >= 1000-5
- num2=num2+5
- if num2 mod 3 <> 0 then '不枚举是3倍数的
- wscript.echo num2
- num=num+num2
- end if
- loop
- wscript.echo "总和:"&num
复制代码
|