Topic Description:
Use the English letter A-Z to represent the value 0-25, forming a numerical representation of the 26 binary. You need to write a method that converts the string of the 26 binary value, in A-Z, to the corresponding 10 binary value.
Input
There are multiple sets of input data, one row for each group, and multiple characters between A-Z.
Output
The number of 10 in the corresponding representation.
Sample input
Ba
Bcd
Gibbon
Goodboy
Sample output
26
731
74962693
2026285376
Package test;
Import Java.util.Scanner;
Class trans{
String target = null;
Long result = 0;
public static long Chengfang (int i) {
Long result = 1;
if (i = = 0)
return result;
result = 1;
for (int j = 0; J < i; J + +) {
Result *= 26;
}
return result;
}
Public trans (String target) {
This.target = target;
}
public void Cal () {
Char c[] = Target.tochararray ();
int j = 0;
for (int i = c.length-1 i >= 0; i--) {
int curr = c[i]-' a ';
result = Curr * Chengfang (j);
j + +;
}
SYSTEM.OUT.PRINTLN (result);
}
}
public class Qunawang {
public static void Main (string[] args) {
TODO auto-generated method stubs
Scanner sin = new Scanner (system.in);
String s = null;
while (Sin.hasnext ()) {
s = Sin.next ();
if (s!= null)
New trans (s). Cal ();
}
}
}