如题

解决方案 »

  1.   

    int x = 20;
    x  = (x << 3) - x;
      

  2.   


    //不用乘法和加法给一个数增加7倍
    public class DivideS
    {
    public static void main(String... args) {
    //
    int x = 8; 
    int a = x << 2;
    int b = x << 1;
    int s = a^b^x;
    System.out.println(s);
    }
    }
      

  3.   


      i -= i<<3;
      System.out.println(-i);
      

  4.   

    (x << 3) - x
      

  5.   

    增加7倍就是变成8倍,左移3位即可:
    x = x << 3;
      

  6.   

    x = x < < 3;
      

  7.   

    果然,
    It's a trap!!!!!!
      

  8.   

    x = x << 3;最佳答案。我想没有更好的方法了吧。
      

  9.   

    //无符号不算最高位的加法,其它的也可以实现吧,减法等于加上它的补码,LZ要几倍都行public class Main {
        public static long sum(long a,long b){
            long c=0;
            long bf1=0x0001,bf=0;
            byte jw=0;
            for(int i=0;i<Long.SIZE;i++){
                long ai=a&(0x0001<<i);
                long bi=b&(0x0001<<i);
                if(ai>0){//1 //为了方便理解用if,不用?:运算
                    if(bi>0){//1
                        if(jw>0){//1
                            jw=1;
                            bf|=0x0001<<i;//确定第i位为1,进1
                        }else{
                            jw=1;//确定第i位为0//进1
                        }
                    }else{//0
                        if(jw>0){//1
                            jw=1;//确定第i位为0//进1
                        }else{
                            jw=0;
                            bf|=0x0001<<i;//确定第i位为1,进0
                        }
                    }
                }else{//0
                    if(bi>0){//1
                        if(jw>0){//1
                            jw=1;//确定第i位为0//进1
                        }else{
                            jw=0;
                            bf|=0x0001<<i;//确定第i位为1,进0
                        }
                    }else{//0
                        if(jw>0){//1
                            jw=0;
                            bf|=0x0001<<i;//确定第i位为1,进0
                        }else{
                            jw=0;//确定第i位为0//进0
                        }
                    }
                }
            }
            return bf;
        }
        public static void main(String[] args) throws FileNotFoundException {
            System.out.println(""+sum(20, 111));
        }
    }
      

  10.   

    不用+运算实现加法
    int Add(int a,int b)
    {
    int jw=a&b;
    int jg=a^b;
    while(jw)
    {
    int t_a=jg;
    int t_b=jw<<1;//进位
    jw=t_a&t_b;//求进位
    jg=t_a^t_b;//求相加的结果,不考虑进位
    }
    return jg;
    }
      

  11.   

    你不懂别乱说,这个其实是让人模拟cpu如何运算,搞清楚计算机如何运算
      

  12.   

    very excellent
    learning~~~~~~~~~~~~~`