简答题 偏难
#23523

01 #include <iostream> 02 #include <string> 03 using namespace std; 04 05 char b…

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 }

未登录也能判分,登录后才会记录
答案与解析
正确答案:(缺答案,待补录)
这道题暂未补解析。