#include<bits/stdc++.h>
#define printCase cout << "Case "<< ++kase<<":"
#define sf scanf
#define pf printf
#define FAST ios_base::sync_with_stdio(false)
using namespace std;
int main()
{
FAST;
unsigned long long a , b;
while(cin >> a >> b){
string s1 , s2 , total;
s1 =bitset<32>(a).to_string();
s2 =bitset<32>(b).to_string();
for (int i = 0; i < s1.length(); ++i)
{
if(s1[i] == '1' && s2[i] !='1' ||s1[i] != '1' && s2[i] =='1' )
total+='1';
else
total+='0';
}
unsigned long long num ;
num = bitset<32>(total).to_ulong();
cout << num << '\n';
}
return 0;
}
Another solution
int main()
{
FAST;
unsigned long long a , b;
while(cin >> a >> b){
unsigned long long num ;
num = a^b;
cout << num << '\n';
}
return 0;
}
#define printCase cout << "Case "<< ++kase<<":"
#define sf scanf
#define pf printf
#define FAST ios_base::sync_with_stdio(false)
using namespace std;
int main()
{
FAST;
unsigned long long a , b;
while(cin >> a >> b){
string s1 , s2 , total;
s1 =bitset<32>(a).to_string();
s2 =bitset<32>(b).to_string();
for (int i = 0; i < s1.length(); ++i)
{
if(s1[i] == '1' && s2[i] !='1' ||s1[i] != '1' && s2[i] =='1' )
total+='1';
else
total+='0';
}
unsigned long long num ;
num = bitset<32>(total).to_ulong();
cout << num << '\n';
}
return 0;
}
Another solution
int main()
{
FAST;
unsigned long long a , b;
while(cin >> a >> b){
unsigned long long num ;
num = a^b;
cout << num << '\n';
}
return 0;
}
No comments:
Post a Comment