28,390
社区成员
发帖
与我相关
我的任务
分享
<%
str = "2,5,20,40,60,38,33,67,22,31,54,32,6,4,9,13,45,6"
str = sortstr(str, ",")
answer = 100
temp = t("",Split(str, ","), answer)
temp_a = Split(temp, "*")
temp1 = "*"
For ii=0 To UBound(temp_a)
'temp2 = sortstr(temp_a(ii), "+")
temp2 = temp_a(ii)
If InStr(temp1, "*" & temp2 & "*")=0 Then
temp1 = temp1 & temp2 & "*"
End If
Next
temp1 = Right(temp1, Len(temp1)-1)
response.write Replace(temp1, "*","<br>")
Function t(a, b, c)
r = ""
a1=a
For i=0 To UBound(b)
b1_str = ""
For j=i+1 To UBound(b)
If b1_str = "" Then
b1_str = b(j)
Else
b1_str = b1_str & "," & b(j)
End If
Next
b1 = Split(b1_str, ",")
If a = "" Then
a1 = b(i)
Else
a1 = a & "+" & b(i)
End If
If eval(a1) < c And UBound(b1)>0 Then
r1 = t(a1, b1, c)
If r1 <> "" Then
If r = "" Then
r = r1
Else
r = r & "*" & r1
End If
End If
ElseIf eval(a1) = c Then
If r = "" Then
r = a1
Else
r = r & "*" & a1
End If
End If
Next
t = r
End Function
Function sortstr(pstr, psign)
pstr_a = Split(pstr, psign)
For i = 0 To UBound(pstr_a)
For j = i To UBound(pstr_a)
If CInt(pstr_a(i))>CInt(pstr_a(j)) Then
k = pstr_a(i)
pstr_a(i) = pstr_a(j)
pstr_a(j) = k
End If
Next
Next
sortstr = ""
For i = 0 To UBound(pstr_a)
If sortstr = "" Then
sortstr = pstr_a(i)
Else
sortstr = sortstr & psign & pstr_a(i)
End If
Next
End Function
%>