Created
September 11, 2017 09:42
-
-
Save danielcooperxyz/675c8172678d448c63594a40e95d8980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Rextester.Program.Main is the entry point for your code. Don't change it. | |
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
namespace Rextester | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
Console.WriteLine("Enter the column number:"); | |
string columnNo = Console.ReadLine(); | |
int columnNumber = int.Parse(columnNo); | |
int dividend = columnNumber; | |
string columnName = String.Empty; | |
int modulo; | |
while (dividend > 0) | |
{ | |
modulo = (dividend - 1) % 26; | |
columnName = Convert.ToChar(65 + modulo).ToString() + columnName; | |
dividend = (int)((dividend - modulo) / 26); | |
} | |
Console.WriteLine("Column ID: " + columnName); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment