使用ASP编程完成该程序

来源:百度知道 编辑:UC知道 时间:2024/05/27 16:19:29
使用ASP编程完成该程序
S=1^2+3^2+5^2+…+99^2,请利用两种循环语句编写程序,计算S的值。(提示:注意步长)。

<%
s=0
For i= 1 To 99 Step 2
s=s+i*i

next
%>

<%=s%>

下面是ASP程序运行的结果:
<%
Dim i,s
s=0
'第一种用for循环
for i=1 to 99 step 2
s = s + i*i
next
Response.Write(s)

'第二种用do...while...loop
s=0
i=1
do while (i<100)
s = s + i*i
i=i+2
loop
Response.Write(s)
%>