( x1 + x2 ) xor x2 = x3现在已知 x1 和 x3 如可求得 x2的值?

解决方案 »

  1.   

    拜托如果你的等号是等于的意思的话:简化后是x1*(!x2)==x3你自己可以搞定了吗
      

  2.   

    a xor b =a*(!b) + (!a)*b
    !(a+b)=(!a)*(!b)
    a*(!a)=0
      

  3.   

    我的代码:
    #include <stdio.h>
    #include <stdlib.h>void myXor(unsigned int x1,unsigned int x3)
    {
      unsigned int x2 = 0 ;
      unsigned int i =  0 ;
      for(x2 = 0 ; x2 < 65535 ; x2 ++)
      {
    if( ((x1+x2)^x2) == x3)
    {
    printf("%d\n",x2) ; 
    return ; 
    }
      }
      printf("Error!") ; 
      return ; }void main(void)
    {
      myXor(10,22) ; 
    }
      

  4.   

    不一定有解啊,就如x1 = 0, x3 != 0,则x2肯定没解
      

  5.   

    nod我只是根据题目给出了程序的实现
    就问题来说确实存在无解的情况
    你说得没错还有多解的情况:x1=x3=0的时候,x2可以任意值