本文发表在 rolia.net 枫下论坛using System;
namespace Z0z0z0
{
....class Program
....{
........public static string Z0ToString(uint number)
........{
............char[] digits = { 'A', '0', 'A', '0', 'A', '0' };
............for (int i = digits.Length -1; i >= 0 && number > 0; --i)
............{
................uint divisor = (uint)(digits[i] == '0' ? 10 : 26);
................digits[i] = (char)(((uint)digits[i]) + number % divisor);
................number /= divisor;
............}
............string z0 = string.Join("", digits);
............return z0;
........}
........static void Main(string[] args)
........{
............Console.WriteLine("Decimal {0}: {1}", 0, Z0ToString(0));
............Console.WriteLine("Decimal {0}: {1}", 1, Z0ToString(1));
............Console.WriteLine("Decimal {0}: {1}", 10, Z0ToString(10));
............Console.WriteLine("Decimal {0}: {1}", 11, Z0ToString(11));
............Console.WriteLine("Decimal {0}: {1}", 123, Z0ToString(123));
............for (uint i = 295; i <= 303; ++i)
............{
................Console.WriteLine("Decimal {0}: {1}", i, Z0ToString(i));
............}
............Console.WriteLine("Decimal {0}: {1}", 939159, Z0ToString(939159));
............Console.WriteLine("Decimal {0}: {1}", 1000001, Z0ToString(1000001));
........}
....}
}
// Output:
Decimal 0: A0A0A0
Decimal 1: A0A0A1
Decimal 10: A0A0B0
Decimal 11: A0A0B1
Decimal 123: A0A0M3
Decimal 295: A0A1D5
Decimal 296: A0A1D6
Decimal 297: A0A1D7
Decimal 298: A0A1D8
Decimal 299: A0A1D9
Decimal 300: A0A1E0
Decimal 301: A0A1E1
Decimal 302: A0A1E2
Decimal 303: A0A1E3
Decimal 939159: B3X2D9
Decimal 1000001: B4U6E1更多精彩文章及讨论,请光临枫下论坛 rolia.net
namespace Z0z0z0
{
....class Program
....{
........public static string Z0ToString(uint number)
........{
............char[] digits = { 'A', '0', 'A', '0', 'A', '0' };
............for (int i = digits.Length -1; i >= 0 && number > 0; --i)
............{
................uint divisor = (uint)(digits[i] == '0' ? 10 : 26);
................digits[i] = (char)(((uint)digits[i]) + number % divisor);
................number /= divisor;
............}
............string z0 = string.Join("", digits);
............return z0;
........}
........static void Main(string[] args)
........{
............Console.WriteLine("Decimal {0}: {1}", 0, Z0ToString(0));
............Console.WriteLine("Decimal {0}: {1}", 1, Z0ToString(1));
............Console.WriteLine("Decimal {0}: {1}", 10, Z0ToString(10));
............Console.WriteLine("Decimal {0}: {1}", 11, Z0ToString(11));
............Console.WriteLine("Decimal {0}: {1}", 123, Z0ToString(123));
............for (uint i = 295; i <= 303; ++i)
............{
................Console.WriteLine("Decimal {0}: {1}", i, Z0ToString(i));
............}
............Console.WriteLine("Decimal {0}: {1}", 939159, Z0ToString(939159));
............Console.WriteLine("Decimal {0}: {1}", 1000001, Z0ToString(1000001));
........}
....}
}
// Output:
Decimal 0: A0A0A0
Decimal 1: A0A0A1
Decimal 10: A0A0B0
Decimal 11: A0A0B1
Decimal 123: A0A0M3
Decimal 295: A0A1D5
Decimal 296: A0A1D6
Decimal 297: A0A1D7
Decimal 298: A0A1D8
Decimal 299: A0A1D9
Decimal 300: A0A1E0
Decimal 301: A0A1E1
Decimal 302: A0A1E2
Decimal 303: A0A1E3
Decimal 939159: B3X2D9
Decimal 1000001: B4U6E1更多精彩文章及讨论,请光临枫下论坛 rolia.net