#include <lintcode.h>
|
static string | convert (long long index) |
|
◆ convert()
string lintcode::convert::Solution::convert |
( |
long long | index | ) |
|
|
static |
- 参数
-
index | the index to be converted |
- 返回
- : return the string after convert.
在文件 lintcode.cpp 第 213 行定义.
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 }
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 }
vector< vector< int > > ans
被这些函数引用 lintcode::convert::TEST(), lintcode::convert::TEST(), lintcode::convert::TEST() , 以及 lintcode::convert::TEST().
该类的文档由以下文件生成: