#include <bits/stdc++.h> using namespace std; int main() { bool TGDCN=true; string s; string a; cin >> s; a=s; if(s[0]=='0'){ cout<<s; }else{ for(int i = 1 ; i < s.size() ; i++) { if(s[i]=='1'){ s[i]='0'; }else{ s[i]='1'; } } cout<<s<<endl; for(int j = 1; j<s.size();j++){ if(s[j]=='1'){ TGDCN = false; }else{ TGDCN =true; } } if(TGDCN==true){ s[s.size()-1]=s[s.size()-1]+1; for(int i=s.size()-1;i>1;i--){ if(s[i]=='2') { s[i]='0'; s[i-1]=s[i-1]+1; } } cout<<s; }else{ cout<<"1"+a; } } return 0; }
标签:std,反码,string,int,补码,main From: https://www.cnblogs.com/hanxuyao/p/17779968.html