Advertisement
stoianpp

durankulak numbers

Jan 4th, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Text.RegularExpressions;
  5.  
  6. class KaspichanNumbers2
  7. {
  8.     static void Main()
  9.     {
  10.         string input = Console.ReadLine();
  11.         Stack<string> num168 = new Stack<string>();
  12.         foreach (Match number in Regex.Matches(input,"[a-z]?[A-Z]"))
  13.         {
  14.             num168.Push(number.Value);
  15.         }
  16.  
  17.         long number10 = 0;
  18.         int position = 0;
  19.         while (num168.Count > 0)
  20.         {
  21.             string currStr = num168.Pop();
  22.             if (currStr.Length == 1)
  23.             {
  24.                 number10 += (currStr[0] - 'A') * (long)Math.Pow(168,position);
  25.             }
  26.             else
  27.             {
  28.                 number10 += ((currStr[1] - 'A') + ((currStr[0] - 'a')+1)*26) * (long)Math.Pow(168, position);
  29.             }
  30.             position++;
  31.         }
  32.         Console.WriteLine(number10);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement