java实现找出能被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){ 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); } } } }
页:
[1]