https://oj.leetcode.com/problems/add-binary/
实” 1 public class Solution {
public String addBinary(String a, String b) {
char c1[]=a.toCharArray();
char c2[]=b.toCharArray();
int len1=a.length();
int len2=b.length();
int lo=len1;
if(len1<=len2)
{
lo=len2;
}
int ans[]=new int[lo+1];
int k=0;
int ia=len1-1;
int ib=len2-1;
int jinwei=0;
while(ia>=0&&ib>=0)
{
ans[k]=c1[ia--]-'0'+c2[ib--]-'0'+jinwei; jinwei=ans[k]/2;
ans[k]=ans[k]%2;
k++; } while(ia>=0)
{ ans[k]=c1[ia--]-'0'+jinwei;
jinwei=ans[k]/2;
ans[k]=ans[k]%2;
k++; }
while(ib>=0)
{ ans[k]=c2[ib--]-'0'+jinwei;
jinwei=ans[k]/2;
ans[k]=ans[k]%2;
k++; }
StringBuffer sbf=new StringBuffer();
if(jinwei==1) sbf.append(1); for(int j=lo-1;j>=0;j--)
{
sbf.append(ans[j]); } return sbf.toString(); }
}