Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class _08_CountOfEqualBitPairs {
  5. public static void main(String[] args) {
  6. @SuppressWarnings("resource")
  7. Scanner str = new Scanner(System.in);
  8. int n = str.nextInt();
  9. String bin = Integer.toBinaryString(n);
  10. int equal = 0;
  11. for (int i = 0; i < bin.length() - 1; i++) {
  12. if (bin.charAt(i) == bin.charAt(i + 1))
  13. equal++;
  14. }
  15. System.out.println(equal);
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement