online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a > b) { int temp; temp = a; a = b; b = temp; } string binaryA = bitset<32>(a).to_string(); string binaryB = bitset<32>(b).to_string(); binaryB.erase(0, binaryB.find_first_not_of('0')); binaryA = binaryA.substr(binaryA.length() - binaryB.length(), binaryA.length()); ; int tempB = bitset<32>(binaryB).to_ulong(); int MSB = 0; int iterator = 0; while (tempB > 0) { if (tempB & 1) { MSB = iterator; } iterator++; tempB = tempB >> 1; } if (a == b) { cout << 0 << endl; } else { for (int i = 0; i < binaryB.length(); i++) { if (binaryA.at(i) == binaryB.at(i)) { if (binaryB[i] == '0') { cout << (binaryB.at(i)); binaryA[i] = '1'; } else { binaryB[i] = '0'; } } } } binaryA[0] = '0'; binaryB[0] = '0'; int a1 = (int)bitset<32>(binaryA).to_ulong(); a1 = int(a1); int b1 = (int)bitset<32>(binaryB).to_ulong(); int ans = (a1 ^ b1); string ANS = to_string(ans); ans = stoi(ANS); // cout << ANS << endl; // ANS.erase(0,ANS.find_first_not_of('0')); cout << ans - 0; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue