【发布时间】:2014-11-05 22:37:07
【问题描述】:
我正在尝试创建一个执行此操作的程序:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA AB AC AD....ZZ AAA AAB AAC
我的处理方式很难用语言表达,但我会尝试解释
我尝试创建一个以 27 为基数的系统并使 A 代表 1、B->2 C->3 和 AA->28 问题是每 27 个字母我得到一个代表 0 的@。
我也尝试让 A 代表 0 并拥有一个以 26 为基数的系统,但是当我需要它为 AA 时,27 将是 BA
public class aaa
{
public static void main(String args[])
{
int counter=29;
for(int x=0;x<=counter;x++)
{
int quotient, remainder;
String result="";
quotient=x;
while (quotient>0)
{
remainder=quotient%27;
result = (char)(remainder+64) + result;
quotient = (int)Math.floor(quotient/27);
}
System.out.print(result+ " ");
}
}
}
这会打印出 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z A@ AA AB
我希望程序执行此操作 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA AB AC
【问题讨论】: