Advertisement
fbinnzhivko

Spy Hard

Mar 20th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. class SpyHard
  5. {
  6.     static void Main(string[] args)
  7.     {  
  8.         int baseOfSystem = int.Parse(Console.ReadLine());
  9.         Console.Write(baseOfSystem);
  10.  
  11.         string message = Console.ReadLine().ToLower();
  12.         Console.Write(message.Length);
  13.  
  14.         int symbolSum = 0;
  15.  
  16.         for (int i = 0; i < message.Length; i++)
  17.         {
  18.             char currentSymbol = message[i];
  19.  
  20.             if (currentSymbol >= 'a' && currentSymbol <= 'z')
  21.             {
  22.                 symbolSum += currentSymbol - 'a' + 1;
  23.             }
  24.             else
  25.             {
  26.                 symbolSum += currentSymbol;
  27.             }
  28.         }
  29.  
  30.         StringBuilder numeralSystemConverter = new StringBuilder();
  31.  
  32.         while (symbolSum > 0)
  33.         {
  34.             numeralSystemConverter.Insert(0, symbolSum % baseOfSystem);
  35.             symbolSum /= baseOfSystem;
  36.         }        
  37.  
  38.         Console.WriteLine(numeralSystemConverter);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement