LintCode刷題筆記-- A+B problem

標籤: 位運算 描述 Write a function that add two numbers A and B. You should not use + or any arithmetic operators. 解題思路: 利用位運算來解決A+B的問題,可以將此問題轉化爲解決不進位相加和進位(carry bit)的兩部分問題: 1. 首先是不進位相加:_A = A^B 先對A和B進行異或運算(
相關文章
相關標籤/搜索