iliya87

02.SpyHadr

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