package nameyu; import java.util.Scanner; public class Test { /** * @param args */ public static void main(String[] args) { int count=0; for(int i=100;i<=1000;i++){ if(i%5==0&&i%6==0){ count++; if(count%10!=0){ System.out.print(i+" "); }else System.out.println(i); } } } }
找出能被5或6整除,但不能被两者同时整除的数 package nameyu; import java.util.Scanner; public class Test { /** * @param args */ public static void main(String[] args) { int count=0; for(int i=100;i<=1000;i++){ if((i%5==0||i%6==0)&&(i%5!=0||i%6!=0)){ count++; if(count%10!=0){ System.out.print(i+" "); }else System.out.println(i); } } } }
|