You are viewing a single comment's thread. Return to all comments →
why is my code not working i mean i am getting the right answer but the compiler says i am wrong.
using namespace std; int main(){ string str1,str2; cin>>str1>>str2; for (int i = 0; i < str1.length(); i++) { if (str1[i]=='0' && str2[i]=='1') { cout<<1; } else if (str1[i]=='1' && str2[i]=='0') { cout<<1; } else { cout<<0; } } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
XOR Strings
You are viewing a single comment's thread. Return to all comments →
why is my code not working i mean i am getting the right answer but the compiler says i am wrong.
include
include
using namespace std; int main(){ string str1,str2; cin>>str1>>str2; for (int i = 0; i < str1.length(); i++) { if (str1[i]=='0' && str2[i]=='1') { cout<<1; } else if (str1[i]=='1' && str2[i]=='0') { cout<<1; } else { cout<<0; }
} return 0; }