packagecom.cxl.demo14;//用while或for循环输出1~100间能被5整除的数,且每行输出3个//while循环publicclassDemo14_2{publicstaticvoidmain(String[] args){int c =0;//计算输出数,每3个跳一行int i =1;while(i <=100){if(i %5==0){System.out.print(i+" ");
c++;}if(c >=3){
c =0;System.out.print("\n");}
i++;}}}
for循环
packagecom.cxl.demo14;//用while或for循环输出1~100间能被5整除的数,且每行输出3个//for循环publicclassDemo14_3{publicstaticvoidmain(String[] args){int c =0;//计算输出数字是否达到3个for(int i =1; i <=100; i++){if(i %5==0){System.out.print(i+" ");
c++;}if(c >=3){
c =0;System.out.println();}}}}