fork download
  1. #include <stdio.h>
  2. #define N 10
  3. int func(int a, int b)
  4. {
  5. if ((a ^ b) < 0)
  6. return 0;
  7. do
  8. a /= 10, b /= 10;
  9. while (a & b);
  10. return (a == b);
  11. }
  12. int main()
  13. {
  14. int a[][2] =
  15. {
  16. { 110, 119},
  17. { -110, -119},
  18. { -110, 119},
  19. { 1234, 214},
  20. { 567, 23},
  21. { 567, -23}
  22. };
  23. for (int i = 0; i < 6; ++i)
  24. printf("%5d, %5d -> %c\n", a[i][0], a[i][1], func(a[i][0], a[i][1]) ? 'T' : 'F');
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
  110,   119 -> T
 -110,  -119 -> T
 -110,   119 -> F
 1234,   214 -> F
  567,    23 -> F
  567,   -23 -> F