Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STRING1 : 011011110011000
- STRING2 : 011001000001000
- EXPECTED OUTPUT : 000010110010000
- for(int i = 0; i<15; i++)
- {
- final_key[i] = STRING1[i] ^ STRING2[i];
- cout<<" XOR = "<<final_key[i];
- }
- final_key[i] = ((STRING1[i]-'0') ^ (STRING2[i]-'0')) + '0';
- #incude <string>
- #incude <bitset>
- #incude <iostream>
- int main()
- {
- std::string s1 = "010101010101010101";
- std::string s2 = "101010101000001111";
- auto result = std::bitset<32>(s1) ^ std::bitset<32>(s2);
- std::cout << result << std::endl;
- }
- char result = std::abs(a - b) + '0';
- string strings_xor(string s, string t) {
- string res = "";
- for(int i = 0; i < s.size(); i++) {
- if(s[i] == t[i])
- res += '0';
- else
- res += '1';
- }
- return res;
- string s1="011011110011000";
- string s2="011001000001000";
- char final_key[15];
- for(int i = 0; i<15; i++)
- {
- final_key[i] = (s1[i] ^ s2[i])+'0'; //paranthesis is important
- cout<<final_key[i];
- }
- final_key[i]=(s1[i]!=s2[i]?'1':'0');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement