Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- //#include<algorithm>
- using namespace std;
- int main()
- {
- int n,t,i,j,cnt=0;
- string a,b;
- cin>>n;
- for(i=0;i<n;i++){
- cin>>t;
- cin>>a;
- cin>>b;
- string ans(a);
- for(j=t-1;j>=0;j--){
- if(a[j]=='1'&&b[j]=='1'){
- //cout<<cnt<<endl;
- if(cnt==1){
- ans[j]='1';
- }
- else {
- ans[j]='0';
- }
- cnt=1;
- }
- else if(a[j]=='0'&&b[j]=='0'){
- //cout<<cnt<<endl;
- if(cnt==1){
- ans[j]='1';
- }
- else{
- ans[j]='0';
- }
- cnt=0;
- }
- else if((a[j]=='0'&&b[j]=='1')||(a[j]=='1'&&b[j]=='0')){
- //cout<<cnt<<endl;
- if(cnt==1){
- ans[j]='0';
- cnt=1;
- }
- else{
- ans[j]='1';
- cnt=0;
- }
- }
- }
- cout<<ans<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement