题解 | #奇偶校验#
奇偶校验
https://www.nowcoder.com/practice/729d11d043d8448e83befa1410b694fe
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
using namespace std;
int main() {
char x;
while (cin >> x) {
int as = x;
int count = 0;
while(as)
{
count = count + ( as % 2 );
as /= 2;
}
if(count % 2 == 0)
x += 128;
cout << bitset<8>(x) << endl;
}
}
