static double 二十六to十(string s)
{
char[] c = s.ToCharArray();
int c_len = c.Length;
double cont = 0;
for (int x = 0; x < c.Length; x++)
{
c_len--;
double 位数 = Math.Pow(26, c_len);
int 数值 = c[x] - 96;
cont += 位数 * 数值;
}
return cont;
}
static string 十to二十六(double d)
{
string val = string.Empty;
long i = 0;
while (d > 26)
{
d = Math.DivRem((long)d, 26, out i);
if (i == 0)
{
d--;
i = 26;
}
val += (char)(96 + i);
}
val += (char)(96 + d);
return new string(val.AsEnumerable().Reverse().ToArray());
}
10进制和26进制互转
最新推荐文章于 2021-11-08 17:03:46 发布