/*Write a function to determine the number of bits required to convert integer A to
integer B
Input: 31, 14
Output: 2
*/
#include <iostream>
#include <bitset>
using namespace std;
int main(){
int a = 31,b = 14, count = 0;
int c = a ^ b;
while(c != 0){
if(c%2) count++;
c = c>>1;
}
cout<<count<<endl;
}
careercup5.5
最新推荐文章于 2018-04-04 17:51:00 发布