找出100-1000之间能被5和6整除的数
能被5和6整除
import java.util.*;
class Main {
public static void main(String[] args){
int count = 0;
for(int i = 100; i <= 1000; i++){
if(i % 5 == 0 && i % 6 == 0){
count++;
System.out.print((count % 10 == 0) ? (i + "\t\n") : (i + "\t"));
}
}
}
}
能被5或6整除,不能同时被两者整除,异或
import java.util.*;
class Main {
public static void main(String[] args){
int count = 0;
for(int i = 100; i <= 200; i++){
if(i % 5 == 0 ^ i % 6 == 0){
count++;
System.out.print((count % 10 == 0) ? (i + "\t\n") : (i + "\t"));
}
}
}
}