我正在尝试创建一个程序,能够实现以下功能: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时却得到了BA。
我的方法很难用语言表达,但我会尝试解释。我尝试创建了一个基于27进制的系统,并使A表示1,B->2,C->3,AA->28。问题在于,每27个字母就会出现一个@表示0。
我还尝试过让A代表0,并使用基于26进制的系统,但是当我需要AA时却得到了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