class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param n int整型
* @return string字符串
*/
string ExcelTitle(int n) {
// write code here
string excel = “ZABCDEFGHIJKLMNOPQRSTUVWXY”;
string s = “”;
//再搞定其他的
while(n > 0)
{
s = excel[n % 26] + s;//先加上最后一位
{
if(n % 26 == 0)
{
n = n - 26;
}
}
n = n / 26;
}
return s;
}
};
牛客网 ----NC336 Excel列名称
最新推荐文章于 2024-06-20 21:03:07 发布