Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class KaspichanNumbers
- {
- const int Base = 256;
- static char[] startingLetter = { '\0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' };
- static string ConvertToKaspichan(ulong remainder)
- {
- string kaspichanNum = null;
- ulong rem = remainder % 26;
- ulong div = remainder / 26;
- char first = (char)(rem + 65);
- kaspichanNum += first.ToString();
- if (div != 0)
- {
- for (int i = 1; i < startingLetter.Length; i++)
- {
- if (div == (ulong)i)
- {
- kaspichanNum += startingLetter[i].ToString();
- break;
- }
- }
- }
- return kaspichanNum;
- }
- static void Main()
- {
- ulong number = ulong.Parse(Console.ReadLine());
- string kaspichan = null;
- while (true)
- {
- ulong remainder = number % Base;
- ulong division = number / Base;
- // convert remainder to kaspichan
- kaspichan += ConvertToKaspichan(remainder);
- if (division == 0)
- {
- break;
- }
- if (division < Base)
- {
- kaspichan += ConvertToKaspichan(division);
- break;
- }
- else
- {
- number /= Base;
- }
- }
- for (int i = kaspichan.Length - 1; i >= 0; i--)
- {
- Console.Write("{0}", kaspichan[i]);
- }
- Console.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement