用VBScript脚本语言实现下面试验

来源:百度知道 编辑:UC知道 时间:2024/09/24 03:24:13
1.用随机函数产生一个0到100之间的数X。并求分段函数Y= 3x-5 ,x>=50
2X+16 ,x< 50
2.求1+(1+3)+(1+3+5)+...+(1+3+5+...+19)

msgbox GetRnd() '第一题
msgbox GetAdd() '第二题
Function GetRnd()
Dim X,Y
Randomize
X=Int(101*Rnd() )
If X>=50 Then
Y=3*x-5
Else
Y=2*x+16
End If
GetRnd=Y
End Function

Function GetAdd()
Dim i,j,X
i=19
X=0
Do While i>0
For j=1 To i
X=X+j+2
j=j+1
Next
i=i-2
Loop
GetAdd=X
End Function