problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
lintcode::convert::Solution类 参考

#include <lintcode.h>

静态 Public 成员函数

static string convert (long long index)
 

详细描述

在文件 lintcode.h117 行定义.

成员函数说明

◆ convert()

string lintcode::convert::Solution::convert ( long long  index)
static
参数
indexthe index to be converted
返回
: return the string after convert.

在文件 lintcode.cpp213 行定义.

213 {
214 unsigned long long prefix = index / 702 + 1;
215 if(index % 702 == 0) {
216 prefix--;
217 index = 702;
218 } else {
219 index %= 702;
220 }
221 auto ans = string();
222 bool round = false;
223 while(index != 0) {
224 char ch = 0;
225 if(round) {
226 ch = static_cast<char>(index % 26 + 63);
227 round = false;
228 } else {
229 ch = static_cast<char>(index % 26 + 64);
230 }
231 if(ch == '@' && index >= 26) {
232 ch = 'Z';
233 round = true;
234 } else if(ch == '?' && index >= 26) {
235 ch = 'Y';
236 round = true;
237 }
238 if('A' <= ch && ch <= 'Z') {
239 ans.insert(0, 1, ch);
240 }
241 index /= 26;
242 }
243 return to_string(prefix) + ans;
244 }

被这些函数引用 lintcode::convert::TEST().


该类的文档由以下文件生成: