12 条回复
package main01;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
public class Main {
public static HashMap<Character, Integer> hashMap = new HashMap<>();
public static void main(String[] args) {
int i=0;
char ch = 'a';
for(;i<26;i++,ch++){
hashMap.put(ch, i);
}
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String string = sc.nextLine();
long result = 0;
int length = string.length()-1;
for(int j=length;j>-1;j--){
result += Math.pow(26,length-j)*hashMap.get(string.charAt(j));
}
System.out.println(result);
}
}
}
添加回复