用VBScript语言编写程序
来源:百度知道 编辑:UC知道 时间:2024/05/05 18:34:43
S=1^2+3^2+5^2+...+99^2,请利用两种循环语句编写程序,计算S的值.
第一种For...next 循环
dim i
dim s
s=0
for i=1 to 99 step 2
s=s+(i xor 2)
next
msgbox "s=" & cstr(s)
第二种while...wend循环
dim i
dim s
i=1
s=0
while i<=99
s=s+(i xor 2)
i=i+2
wend
msgbox "s=" & cstr(s)
其实还有其他循环方式。