while True:
try:
dict1 = {'A': 10, 'J': 18, 'S': 26, 'B': 11, 'K': 19, 'T': 27, 'C': 12, 'L': 20, 'U': 28,
'D': 13, 'M': 21, 'V': 29, 'E': 14, 'N': 22, 'W': 32, 'F': 15, 'O': 35, 'X': 30,
'Y': 31, 'G': 16, 'H': 17, 'Q': 24, 'Z': 33, 'I': 34, 'R': 25, 'P': 23}
id_text = input()
en = str(dict1[id_text[0].upper()])
total = int(en[0]) + int(en[1]) * 9 + int(id_text[len(id_text) - 1])
id_text = id_text[1:9]
n = 8
for i in id_text:
total += int(i) * n
n -= 1
print("real" if total % 10 == 0 else "fake")
except:
break
怎麼把這段改成C++
#include <iostream>
#include <string>
#include <unordered_map>
int main() {
std::unordered_map<char, int> dict1 = {
{'A', 10}, {'J', 18}, {'S', 26}, {'B', 11}, {'K', 19}, {'T', 27},
{'C', 12}, {'L', 20}, {'U', 28}, {'D', 13}, {'M', 21}, {'V', 29},
{'E', 14}, {'N', 22}, {'W', 32}, {'F', 15}, {'O', 35}, {'X', 30},
{'Y', 31}, {'G', 16}, {'H', 17}, {'Q', 24}, {'Z', 33}, {'I', 34},
{'R', 25}, {'P', 23}
};
std::string id_text;
while (std::cin >> id_text) {
int total = 0;
char first_char = toupper(id_text[0]);
int en = dict1[first_char];
total += en / 10 + en % 10 * 9 + id_text[id_text.size() - 1] - '0';
id_text = id_text.substr(1, 8);
int n = 8;
for (char c : id_text) {
total += (c - '0') * n;
n--;
}
std::cout << (total % 10 == 0 ? "real" : "fake") << std::endl;
}
return 0;
}