Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace ConsoleApplication3
- {
- class Program
- {
- static string ReverseString(string result)
- {
- char[] reversedResult = result.ToCharArray();
- Array.Reverse(reversedResult);
- return new string(reversedResult);
- }
- //Поради някаква причина ми изкарва резултата наобратно (вместо abc примерно, ми дава cba) та затова съществува горния метод
- static void Main(string[] args)
- {
- string[] userInput = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
- for (int i = 0; i < userInput.Length; i++)
- {
- string inputWord = userInput[i];
- BigInteger decResult = 0;
- for (int j = inputWord.Length - 1, power = 0; j >= 0; j--, power++)
- {
- BigInteger letter = inputWord[j] - 'a';
- decResult += letter * BigInteger.Pow(23, power);
- }
- BigInteger anotherDecResult = decResult;
- string result = string.Empty;
- string anotherResult = string.Empty;
- while (anotherDecResult > 0)
- {
- BigInteger anotherLetterAsNumber = anotherDecResult % 23;
- anotherDecResult /= 23;
- char anotherLetterAsLetter = (char)(anotherLetterAsNumber + 'a');
- result += anotherLetterAsLetter;
- }
- Console.Write(ReverseString(result) + " = ");
- Console.Write(decResult);
- Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement