package com.lovecoding.day03;

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

    }

    public static void m5(){
        int i = 0; // 1  0
        int result = ++i/--i;
        System.out.println("result="+result);
        //ArithmeticException: / by zero 1/0 异常
    }

    public static void m4(){
        int i = 1;
        // i = 1 2 3 4 5   j = 14
        //      2     2     4     4
        int j = ++i + i++ * ++i + i++;

        System.out.println("i = " + i);
        System.out.println("j = " + j);
    }
    public static void m3() {
        int i = 1;
        int j = i++;  //j=1 2 1  i=2 3 2
        //    = 2   *   2  +  2 *  2
        int k = i++ * ++j + --i *  j--;

        System.out.println("i = " + i); //2
        System.out.println("j = " + j); //1
        System.out.println("k = " + k); //8
    }

    public static void m2() {
        int i = 1;
        int j = i++;  // j = 1  i=2
        //  i取值2   i = 3
        //  j取值2   j = 2
        //  i取值4   i = 4
        //  j取值2   j = 3
        //  k = 2 * 2 + 4 * 2  = 12
        int k = i++ * ++j + ++i * j++;

        System.out.println("i = " + i); //4
        System.out.println("j = " + j); //3
        System.out.println("k = " + k); //12
    }
    public static void m1() {
        int i = 1234; // 1230+4   // 123  //12


        //ge
        int ge = i % 10;

        //shi
        int shi = i/10%10;

        System.out.println(ge);
        System.out.println(shi);
    }
}
