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
- string convertToTitle(int n) {
- if(n==0) {
- return "";
- }
- string result="";
- while(n!=0) {
- int mod = n%26;
- if(mod == 0) {
- mod = 26;
- }
- char zifu = 'A' + mod - 1;
- result = zifu + result ;
- n = n/26;
- if(mod == 26) n--;
- }
- return result;
- }

浙公网安备 33010602011771号