package com.lovecoding.day03;

public class Test05_SuanShu_ex02 {
    //获取一个四位数的个位，十位，百位，千位
    public static void main(String[] args) {
        m4_1();

    }

    public static void m4_1 ()  {
        boolean x = true;
        boolean y = false;
        short z = 42;

        if(y=true)
            if((z++==42)&&(y==true)) //true z=43
                z++; // z=44


        if((x=false) || (++z==45))  z++; //z=46

        System. out.println("z="+z); //z=46
    }


    public static void m4(){
        boolean x = true;
        boolean y = false;
        short z = 42;
        // z=43 true  false  = false
        if((z++==42)&&(y==true)) z++;
        //false || false z=44
        if((x=false) || (++z==45)) z++;

        System. out.println("z="+z); //z = 44
    }

    public static void m3_3(){
        int x = 1,y = 1;

        if(x++==1 || ++y==1){ //x=2  true
            x =7;
        }
        System.out.println("x="+x+",y="+y); //x=7  y=1

    }

    public static void m3_2(){
        int x = 1,y = 1;

        if(x++==1 | ++y==1){ // true x=2 false y=2
            x =7;
        }
        System.out.println("x="+x+",y="+y); //x=7 y=2
    }

    public static void m3_1(){
        int x = 1,y = 1;
        //x = 1
        if(x++==2 && ++y==2){
            x =7;
        }
        System.out.println("x="+x+",y="+y); //x=2   y=1
    }
    public static void m3_0(){
        int x = 1;
        int y = 1;

        if(x++==2 & ++y==2){ //false x=2  y=2
            x =7;
        }
        System.out.println("x="+x+",y="+y); //x=2   y=2
    }

    public static void m2(){
        int a = 1;
        int b = 2;
        int c = 0;
        boolean flag = false;
        if(flag=true){ // true
            c = a++ + b; //执行
            // a 取 1  a=2
            // c = 1+2  = 3
        }

        if(flag=false){ // false
            c = ++a - b;
        }
        System.out.println("a = " + a); //2
        System.out.println("b = " + b); //2
        System.out.println("c = " + c); //3
    }
    public static void m1(){
        int a = 1;
        int b = 2;
        int c = 0;
        boolean flag = false;
        if(flag==true){
            c = a++ + b; //不会执行
        }

        if(flag==false){ //true
            c = ++a - b; //会执行
            // a = 2  b = 2
            // c = 0;
        }
        System.out.println("a = " + a); //2
        System.out.println("b = " + b); //2
        System.out.println("c = " + c); //0
    }
}
