Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int table[7][7];
- string toBinary(int n)
- {
- string s;
- while(n)
- {
- s.push_back((n%2)+'0');
- n/=2;
- }
- reverse(s.begin(),s.end());
- return s;
- }
- int main()
- {
- int temp=0;
- string data,binaryBlock;
- cin>>data;
- for(int i=0; i<data.size(); i++)
- {
- temp=data[i];
- binaryBlock=toBinary(temp);
- for(int j=6,k=binaryBlock.size()-1; j>=0 and k>=0; j--,k--)
- {
- table[i][j]=binaryBlock[k]-48;
- }
- }
- string ans="";
- for(int i=0; i<7; i++)
- {
- int countP=0;
- for(int j=0; j<data.size(); j++)
- {
- if(table[j][i])
- countP++;
- }
- if(countP%2)
- ans+='1';
- else
- ans+='0';
- }
- cout<<ans<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement