题解 | 奇偶校验
#include <iostream>
#include <string>
#include <bitset>
using namespace std;
char parity_check(char c) {
char check=1,temp = c;
while (temp != 0) {
check ^= (temp&1);
temp>>=1;
}
return c+(check << 7);
}
int main() {
string str;
while (cin >> str) {
for (int i = 0; i < str.length(); i++) {
cout << bitset<8>(parity_check(str[i])) << endl;
}
}
}
