(int x, int y)
| 2 | class Hamming |
| 3 | { |
| 4 | static int hammingDistance(int x, int y) |
| 5 | { |
| 6 | int n = x ^ y; |
| 7 | int setBits = 0; |
| 8 | |
| 9 | while (n > 0) |
| 10 | { |
| 11 | setBits += n & 1; |
| 12 | n >>= 1; |
| 13 | } |
| 14 | |
| 15 | return setBits; |
| 16 | } |
| 17 | public static void main(String[] args) |
| 18 | { |
| 19 | Scanner sc = new Scanner(System.in); |