日期:2014-05-17  浏览次数:21110 次

数字置换问题
有一个数字,比如 830 如何实现把每位数字置换成字母:

0----A
1----B
2----C
3----D
4----E
5----F
6----G
7----H
8----I
9----J

830则换成 IDA

要asp的实现方法,谢谢!

------解决方案--------------------
<%
function toStr(n)
arr=array("A","B","C","D","E","F","G","H","I","J")
for i=1 to len(n)
m=mid(n,i,1)
n=replace(n,m,arr(m))
next
toStr=n
end function
%>
<%
response.write toStr("830")
%>
------解决方案--------------------
VBScript code
arrChr=array("A","B","C","D","E","F","G","H","I","J")
n=830
for i=1 to len(n)
 s=s&arrChr(mid(n,i,1))
next

response.write s

------解决方案--------------------
VB code
<%
function to_character(str)
dim arr,i,n,list
arr=split("A|B|C|D|E|F|G|H|I|J","|")
for i=1 to len(str)
    n=mid(str,i,1)
    if IsNumeric(n) then
        n=arr(n)
    end if
    list=list&n
next
to_character=list
end function

Response.write to_character("830")&"<br/>"
Response.write to_character("52df12")
%>

------解决方案--------------------
HTML code

<%
    function n2s(s)
        abc = ucase("abcdefghij")
        tmp = ""
        for i=1 to len(s)
            tmp = tmp & mid(abc, mid(s, i, 1) + 1, 1)
        next
        n2s = tmp
    end function
        
    response.write n2s("830")
%>

<script type="text/javascript">
    String.prototype.test = function(){
        var t = this;
        var s = 'abcdefghij'.toUpperCase();
        var a = t.split('');
        for(var i =0, len = a.length; i < len; i++){
            a[i] = s.charAt(a[i])
        }
        return a.join('');
    }
    alert( '830'.test() );
</script>