作业帮 > 综合 > 作业

【vbs】1000到9999之间有多少个各位数字不同

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/23 10:06:48
【vbs】1000到9999之间有多少个各位数字不同
求该VBS,谢谢
dim num,c,i,bool,chr
for c=1000 to 9999
for i=1 to 3
if instr(instr(1,c,mid(c,i,1))+1,c,mid(c,i,1))0 then
bool=false
exit for
else
bool=true
end if
next
if bool then num=num+1:chr=chr & c & vbCr
next
msgbox num
msgbox chr
总共4536个
第二种方法,要简单点,.
dim num,c,i,bool,chr,arr()
for c=1000 to 9999
redim arr(10)
for i=1 to 4
if arr(mid(c,i,1))=true then
bool=false
exit for
else
arr(mid(c,i,1))=true
bool=true
end if
next
if bool then num=num+1:chr=chr & c & vbCr
next
msgbox num
msgbox ch