package aa;
public class YY { //创建类
public static void main(String[] args) {
// TODO 自动生成的方法存根
int i_x=1; //定义变量
int i_y=2;
int i_m=3,i_n=3;
int r_m,r_n;
float d_x=13.5f;
float d_y=3.0f;
System.out.println(i_x +"+"+i_y+"="+(i_x+i_y)); //整型变量的+ - * / %运算
System.out.println(i_x+"*"+i_y+"="+(i_x*i_y));
System.out.println(i_x+"/"+i_y+"="+(i_x/i_y));
System.out.println(i_x+"%"+i_y+"="+(i_x%i_y));
System.out.println(d_x+"-"+d_y+"="+(d_x-d_y));
System.out.println(d_x+"*"+d_y+"="+(d_x*d_y)); //整型变量和单精度浮点型变量的混合乘运算
System.out.println(d_x+"/"+d_y+"="+(d_x/d_y));
System.out.println(d_x+"%"+d_y+"="+(d_x%d_y));
System.out.println(i_y+"*"+d_y+"="+(i_y*d_y));
r_m=++i_m;
r_n=i_n++;
System.out.println("r_m=++i_m,r_m="+r_m+",i_m="+i_m); //整型变量的自增运算
System.out.println("r_n=i_n++,r_n="+r_n+",i_n="+i_n);
}
}
运行结果:
知识点:
算术运算符主要用于算术运算,包括单目算术运算符(+ - ++ –)和双目算术运算符(+ - * / %)