Created
January 11, 2012 16:01
-
-
Save kuoe0/1595344 to your computer and use it in GitHub Desktop.
Google Intern Worksheet - http://kuoe0.ch/313/2011-google-intern-worksheet/
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
const char* toExcelColumnName( int n ) { | |
string ret = ""; | |
while ( n ) { | |
int x = n % 26; | |
if ( x ) | |
ret += 'A' + x - 1; | |
else | |
ret += 'Z', n -= 26; | |
n /= 26; | |
} | |
reverse( ret.begin(), ret.end() ); | |
return ret.c_str(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment