01 #include <iostream>
02 #include <string>
03 using namespace std;
04
05 char base[64];
06 char table[256];
07
08 void init()
09 {
10 for (int i = 0; i < 26; i++) base[i] = 'A' + i;
11 for (int i = 0; i < 26; i++) base[26 + i] = 'a' + i;
12 for (int i = 0; i < 10; i++) base[52 + i] = '0' + i;
13 base[62] = '+', base[63] = '/';
14
15 for (int i = 0; i < 256; i++) table[i] = 0xff;
16 for (int i = 0; i < 64; i++) table[base[i]] = i;
17 table['='] = 0;
18 }
19
20 string decode(string str)
21 {
22 string ret;
23 int i;
24 for (i = 0; i < str.size(); i += 4) {
25 ret += table[str[i]] << 2 | table[str[i + 1]] >> 4;
26 if (str[i + 2] != '=')
27 ret += (table[str[i + 1]] & 0x0f) << 4 | table[str[i +
2]] >> 2;
28 if (str[i + 3] != '=')
29 ret += table[str[i + 2]] << 6 | table[str[i + 3]];
30 }
31 return ret;
32 }
33
34 int main()
35 {
36 init();
37 cout << int(table[0]) << endl;
38
39 string str;
40 cin >> str;
41 cout << decode(str) << endl;
42 return 0;
43 }
(1).设输入字符串长度为 n,decode 函数的时间复杂度为( )。
| A.
|
B. Θ(n) |
| C. Θ(n log n) |
D. Θ(n2) |
可能存在输入不同,但输出的第二行相同的情形。( )
| A.正确 | B.错误 |
当输入为“Y3Nx”时,输出的第二行为( )。
| A. “csp” |
B. “csq” |
| C. “CSP” |
D. “Csp” |
输出的第一行为“-1”。( )
| A.正确 | B.错误 |
输出的第二行一定是由小写字母、大写字母、数字和“+”、“/”、“=”构成的字符串。( )
| A.正确 | B.错误 |
当输入为“Y2NmIDIwMjE=”时,输出的第二行为( )。
| A. “ccf2021” |
B. “ccf2022” |
| C. “ccf 2021” |
D. “ccf 2022” |












