#include <iostream>
#include <cassert>
using namespace std;
int ssDecodeColID(const string& col) {
int x = 0;
for (const char &c : col) {
x = x * 26 + c - 'A' + 1;
}
return x;
}
string rand_string(int len) {
string ret;
while (len--) {
ret.push_back('A' + rand() % 26);
}
return ret;
}
int main(int argc, char *argv[]) {
srand(time(nullptr));
assert(1 == ssDecodeColID("A"));
assert(27 == ssDecodeColID("AA"));
if (argc == 2) {
cout << argv[1] << " " << ssDecodeColID(argv[1]) << endl;
} else {
string s(rand_string(1 + rand() % 5));
cout << s << " " << ssDecodeColID(s) << endl;
}
return 0;
}
EPI 5.8 SPREADSHEET COLUMN ENCODING
最新推荐文章于 2023-12-19 16:08:48 发布