首页 > 其他 > 详细

数字转表格标题 Excel Sheet Column Title

时间:2015-07-17 00:08:28      阅读:309      评论:0      收藏:0      [点我收藏+]

#include<string>
using namespace std;
class Solution {
public:
   string convertToTitle(int n) {
         string res;
         if(n<=0) return "";
       while(n)
    {
      res+=(n-1)%26+‘A‘;   //[n-1]这里一定要想明白了,注意头尾两个数据的验证
      n=(n-1)/26;
    }
    reverse(res.begin(),res.end());
    return res;
  }
};

数字转表格标题 Excel Sheet Column Title

原文:http://www.cnblogs.com/julie-yang/p/4652775.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!