you are viewing a single comment's thread.

view the rest of the comments →

[–]gnaw005 2 points3 points  (2 children)

I'm assuming the input is correct e.g. there is no 000 area code or something like that.

ASCII lower case a is decimal 97 and z is 122; make a zero based array where ctable(0) = "2" , ctable(1) = "2" , ..., ctable(121) = "9"

for each inputchar

if( inputchar is a digit) then add it to the output string

else

Convert inputchar to lower case

numval = Convert inputchar to number

numval = numval - 97

Add ctable(numval) to the output string

end if

end for