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;
- namespace CSharpTwoExam
- {
- class Program
- {
- public static int numBase = 19;
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split();
- string result = String.Empty;
- string currentNumber = String.Empty;
- string[] resultNumber;
- int theResult = 0;
- int mainResult = 0;
- for (int k = 0; k < input.Length; k++)
- {
- for (int i = 0; i < input[k].Length; i++)
- {
- currentNumber += getCurrentNumber(input[k][i].ToString()) + " ";
- }
- resultNumber = currentNumber.Split();
- for (int i = resultNumber.Length - 2; i >= 0; i--)
- {
- theResult += int.Parse(resultNumber[i]) * powerOfNineteen(resultNumber.Length - i - 2);
- }
- mainResult += theResult;
- theResult = 0;
- currentNumber = String.Empty;
- }
- string nineteenResult = String.Empty;
- int saveMain = mainResult;
- while (mainResult > 0)
- {
- int digit = mainResult % 19;
- nineteenResult += checkNuber(digit.ToString());
- mainResult /= 19;
- }
- char[] theResultBro = nineteenResult.ToCharArray();
- Array.Reverse(theResultBro);
- Console.WriteLine( new string(theResultBro) + " = " + saveMain);
- }
- public static string checkNuber(string number)
- {
- string theNumber = String.Empty;
- string alphabeth = "abcdefghijklmnopqrs";
- for (int i = 0; i < alphabeth.Length; i++)
- {
- if (number == i.ToString())
- {
- theNumber = alphabeth[i].ToString();
- }
- }
- return theNumber;
- }
- public static string getCurrentNumber(string input)
- {
- string alphabeth = "abcdefghijklmnopqrs";
- string result = string.Empty;
- for (int i = 0; i < input.Length; i++)
- {
- for (int j = 0; j < alphabeth.Length; j++)
- {
- if (input[i] == alphabeth[j])
- {
- result = j.ToString();
- break;
- }
- }
- }
- return result;
- }
- public static int powerOfNineteen(int power)
- {
- int result = 1;
- for (int i = 0; i < power; i++)
- {
- result *= 19;
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement