fork download
  1. #include <stdio.h>
  2.  
  3. /*Расстояние Хэмминга*/
  4. int distance(int u, int v){
  5. int d = 0;
  6. while(u > 0){
  7. d = d + ((u&1) ^ (v&1));
  8. u = u >> 1;
  9. v = v >> 1;
  10. }
  11. return d;
  12. }
  13.  
  14. void main(void){
  15. /*11011 и 10001*/
  16. printf("%d", distance(27, 17));
  17. }
Runtime error #stdin #stdout 0s 2052KB
stdin
Standard input is empty
stdout
2