Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB
十进制转换为二十六进制,其中n--是很关键的一步
class Solution { public: string convertToTitle(int n) { int i,j,mod; string s; char num; while(n>0) { n--; mod=n%26; num='A'+mod; s=num+s; n=n/26; } return s; } };
版权声明:本文为博主原创文章,未经博主允许不得转载。