Advertisement
EvlogiHr

ExcelColumns

Dec 29th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. using System;
  2.  
  3. class ExcelColumns
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.  
  9.         long index = 0;
  10.         for (int i = n - 1; i >= 0; i--)
  11.         {
  12.             string letter = Console.ReadLine();
  13.             int ch = Convert.ToChar(letter) - '@';
  14.             index += ch * (long)Math.Pow(26, i);
  15.         }
  16.         Console.WriteLine(index);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement