Advertisement
fbinnzhivko

Spy hard

Mar 20th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2. using System.ComponentModel.Design;
  3. using System.Linq;
  4.  
  5. class Program
  6. {
  7.     static void Main()
  8.     {
  9.         int numeralSystem = int.Parse(Console.ReadLine());
  10.         string input = Console.ReadLine();
  11.  
  12.         int totalvalue = 0;
  13.         string convertedValue = null;
  14.  
  15.         for (int i = 0; i < input.Length; i++)
  16.         {
  17.             if (input[i] >= 'A' && input[i] <= 'Z')
  18.             {
  19.                 totalvalue += input[i ] - 64;
  20.             }
  21.             else if (input[i] >= 'a' && input[i] <= 'z')
  22.             {
  23.                 totalvalue += input[i]-96;
  24.             }
  25.             else
  26.             {
  27.                 totalvalue = totalvalue + input[i];
  28.             }
  29.         }
  30.         do
  31.         {
  32.             convertedValue = (totalvalue % numeralSystem) + convertedValue;
  33.             totalvalue /= numeralSystem;
  34.  
  35.         } while (totalvalue != 0);
  36.  
  37.         Console.WriteLine(numeralSystem.ToString() + input.Length + convertedValue);
  38.         //convertedValue.ToCharArray().Reverse().ToList().ForEach(c => Console.Write(c));
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement