| 
 
| import java.util.Scanner; //这个代码有点意思
 
 public class AA {
 public static void main(String[] args) {
 OK:
 while (true) {
 
 System.out.println("输入一串大写字母");
 Scanner sc = new Scanner(System.in);
 String str = sc.next();
 char[] chars = str.toCharArray();
 int l = chars.length;
 long sum = 0;
 for (int i = 0; i < chars.length; i++, l--) {
 if (chars[i]<65 || chars[i]>90){
 System.out.println("输入的不是纯大写字母");
 System.out.println("================================");
 continue OK;
 }
 int x = 1;
 for (int j = 0; j < l-1; j++) {
 x = 26 * x;
 }
 long count = (chars[i] - 64) * x;
 sum += count;
 
 }
 System.out.println(sum);
 System.out.println("================================");
 }
 }
 }
 | 
 |