package com.lovecoding.day03;

public class Test10_IF02_EX {
    public static void main(String[] args) {
        //两个数字的交互
        int a=10;
        int b=20;

        System.out.println("a="+a);
        System.out.println("b="+b);
        //交换 **
        //声明临时变量
        int temp = a;
        a = b;
        b = temp;

        System.out.println("交换之后");
        System.out.println("a="+a);
        System.out.println("b="+b);

        int x=10;
        int y=20;
        //加减法 可能溢出
        int i = x + y;
        x = i - x;
        y = i - x;
        System.out.println("交换之后");
        System.out.println("x="+x);
        System.out.println("y="+y);


        //亦或 ^
        int e =10;
        int f =20;

        int i1 = e + f;
        e = i1 ^ e; //
        f = i1 ^ e;

        System.out.println(e);
        System.out.println(f);

    }
}
