Venciity

[SoftUni C# exam preparation] 03.ExcelColumns

Apr 9th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. /*Condition : https://www.dropbox.com/s/zarb2ikd6qaptcu/3.%20Excel%20Columns.doc */
  2. using System;
  3.  
  4.     class ExcelColumns
  5.     {
  6.         static void Main()
  7.         {
  8.             string str = "";
  9.             int n = Int32.Parse(Console.ReadLine());
  10.             long number = 0;
  11.  
  12.             for (int i = 0; i < n; i++)
  13.             {
  14.                 str += Console.ReadLine();
  15.             }
  16.  
  17.             for (int i = 0; i < str.Length; i++)
  18.             {
  19.                 number *= 26;
  20.                 number += (str[i] - 'A' + 1);
  21.             }
  22.             Console.WriteLine(number);
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment