例如输入a: 输出1 输入aa: 输出27 本人IT菜鸟,代码有问题请多指教 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 #include<iostream> #include<string> #include<math.h> using namespace std; void main() { char str[10]; cin>>str; int len=strlen(str); int number=0; int j=0; for(int i=len-1;i>=0;i--) { if(str[i]=='a') { int x=1; number=number+x*pow(26,j); } else { number=number+(str[i]-'a'+1)*pow(26,j); } j++; } cout<<number; }