题目:https://leetcode.com/problems/add-binary/tabs/description
代码:
class Solution {
public:
string addBinary(string a, string b) {
int i = a.size()-1,j = b.size()-1,temp=0;
string c;
while(i>=0|j>=0|temp==1){
if(i>=0){
temp+=a[i--]-'0';
}
if(j>=0){
temp+=b[j--]-'0';
}
c+=char(temp%2+'0');
temp=temp/2;
}
reverse(c.begin(),c.end());
return c;
}
};