Created
July 27, 2014 03:45
-
-
Save chrislukkk/524fd7436421a8602ddb to your computer and use it in GitHub Desktop.
Career cup 5.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Chapter5; | |
public class CountFlip { | |
public static int flipCount(int fir, int sec) { | |
int count = 0; | |
int res = fir ^ sec; | |
while(res != 0) { | |
count += res%2; | |
res /= 2; | |
} | |
return count; | |
} | |
public static void main(String[] args) { | |
System.out.println(flipCount(10, 11)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment