伪代码:
for i=n-1 downto 0 if A[i]+B[i]==0 //情况1 if flag==0 C[i+1]=0 else C[i+1]=1 flag=0 elseif A[i]+B[i]==1 //情况2 if flag==0 C[i+1]=1 else C[i+1]=0 flag==1 else //情况3 if flag==0 C[i+1]=0 else C[i+1]=1 flag==1C[0]=flag
时间: 2024-10-04 12:53:12
伪代码:
for i=n-1 downto 0 if A[i]+B[i]==0 //情况1 if flag==0 C[i+1]=0 else C[i+1]=1 flag=0 elseif A[i]+B[i]==1 //情况2 if flag==0 C[i+1]=1 else C[i+1]=0 flag==1 else //情况3 if flag==0 C[i+1]=0 else C[i+1]=1 flag==1C[0]=flag