package day03;ide
/**函數
* 取餘數運算 %spa
* 1) 負數的餘數是負數或0orm
* 2)正數方向,餘數是周期函數it
* 3)取餘運算常常用於處理週期性現象class
*/static
public class Demo08 {di
public static void main(String[] args) {view
int a = 5;vi
int b = 2;
int c = a % b;//5/2 得2餘1
System.out.println(c);//1
System.out.println(-4%3);// -4/3 得-1餘-1
System.out.println(-3%3);//0
System.out.println(-2%3);// -2/3 得0餘-2
System.out.println(-1%3);// -1/3 得0餘-1
System.out.println(0%3);// 0/3 得0餘0
System.out.println(1%3);//1
System.out.println(2%3);//2
System.out.println(3%3);//0
System.out.println(4%3);//1
System.out.println(5%3);//2
System.out.println(6%3);//0
System.out.println(7%3);//1
System.out.println(8%3);//2
}
}