在一次面试的过程中有一道题:给你一个数字字符串:str="11,33,22,33,44,55,111,22,444,22,44,555",要求用asp实现,去掉这个字符串中重复的数字,代码如下:
<%
str="11,33,22,33,44,55,111,22,444,22,44,555"
response.write "开始前:"&str&"<br>"
a=split(str,",")
str2=""
for i=0 to ubound(a)
if instr(","&str2&",",","&a(i)&",")<=0 then
str2=str2&","&a(i)
end if
next
response.write "结果:"
if len(str2)>0 then str2=right(str2,len(str2)-1)
response.write str2&"<br />"
%>(鼠标移到代码上去,在代码的顶部会出现四个图标,第一个是查看源代码,第二个是复制代码,第三个是打印代码,第四个是帮助)
