kuoe0
1/11/2012 - 4:01 PM

Google Intern Worksheet - http://kuoe0.ch/313/2011-google-intern-worksheet/

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();
}