思路:
利用位运算
C++:
#include <iostream>
using namespace std; int main()
{
int a = , b = ;
int sum, carry;
do
{
sum = a ^ b;
carry = (a & b) << ;
a = sum;
b = carry;
}
while(b != ); cout<<a;
}
2023-08-19 13:28:40
思路:
利用位运算
C++:
#include <iostream>
using namespace std; int main()
{
int a = , b = ;
int sum, carry;
do
{
sum = a ^ b;
carry = (a & b) << ;
a = sum;
b = carry;
}
while(b != ); cout<<a;
}