Convert string to number [Java]

1. Topic

The string 0 to 9 represents the numbers 0 to 9, the string A represents 10, B represents 11, C represents 12, and so on, Z represents 35, 10 represents 36, and 11 represents 37. Programming: Input a string, and calculate the number represented by the string according to the above rules. For example: input G, output 16; input 28, output 80.

Two, ideas

Although the title of this question is: Converting a string to a number, there is no explicit conversion of the base system, but it is not difficult to find that this question is to convert the 36-ary system into a decimal system.

First write the conversion of a single string as a function:

    public static int nums(Character ch){
   
    
    
        int ans 

Guess you like

Origin blog.csdn.net/qq_38689263/article/details/127718843