关于用VB脚本编程的问题

来源:百度知道 编辑:UC知道 时间:2024/05/23 02:09:56
1.编写VBScript代码,提示用户输入N,在页面上输出N的因子之和。例如用户输入8,页面上输出:1+2+4+8=15
2.编写VBScript代码,生成n个1000以内的随机整数,统计其中大于或小于500的数的个数及其所占的百分比,要求n由InputBox函数输入,将其结果显示在页面上。如某次n输入为800,显示结果为“生成800个1000以内的数,其中小于500数有406个,占50.75%,大于500的数有394个,占49.25%”。

我在线等啊

第一个问题
n=inputbox("请输入一个数字:","提示","8")
for i=1 to n
for j=i to n
if i*j=cint(n) and i<>j then
sm=sm & i & " " & j & " "
elseif i*j=cint(n) and i=j then
sm=sm & i & " "
end if
next
next
s=split(sm," "):l=ubound(s)
msgbox px(l)

function px(a)
for i=0 to a-1
for j=i to a-1
if cint(s(i))>=cint(s(j)) then tmp=s(i):s(i)=s(j):s(j)=tmp
next
next
for i=0 to a-1
px=px & s(i) & "+"
next
px=left(px,len(px)-1)
px=cstr(px) & "=" & eval(px)
end function

1.
Dim num,Sqrt,Total
num = InputBox("请输入一个整数:")
If num = "" Or Not IsNumeric(num) Or InStr(num,".") <> 0 Then
WScript.Echo "你输入的"&num&&qu