【C语言Coding】第二天
原创
©著作权归作者所有:来自51CTO博客作者小样小响的原创作品,请联系作者获取转载授权,否则将追究法律责任
int sum(int num1, int num2){
return num1+num2;
}
bool squareIsWhite(char * coordinates){
switch(coordinates[0]){
case 'a': case 'c': case 'e': case 'g':
if(((int)*(coordinates+1)) % 2 == 0){
return true;
}
break;
default:
if (((int)*(coordinates+1)) % 2 != 0){
return true;
}
}
return false;
}
int findDelayedArrivalTime(int arrivalTime, int delayedTime){
return (arrivalTime+delayedTime)%24;
}
int hammingWeight(uint32_t n) {
int num = 32;
int count = 0;
while(num-- > 0){
if (n%2==1){
count++;
}
n = n>>1;
}
return count;
}
int hammingDistance(int x, int y){
int z = x ^ y;
int num = 32;
int count = 0;
while(num-- > 0){
if (z % 2 == 1){
count++;
}
z /= 2;
}
return count;
}
int add(int a, int b){
while( b!=0 ){
unsigned int key = (unsigned int)(a & b)<<1;
a = a^b;
b = key;
}
return a;
}