* 100以内的数逢7就去掉
*/
public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 1; i < 100; i++) {
list.add(i);
} 刚刚发的那个代码我忘了增强for循环是不能删除的, 现在用for循环做的
for (int i = 0; i < list.size(); i++) {
if (list.get(i) % 10 == 7) {
list.remove(list.get(i));
} else if (list.get(i) % 7 == 0) {
list.remove(list.get(i));
} else if (list.get(i) / 10 == 7) {
list.remove(list.get(i));
} else {
System.out.print(list.get(i) + " ");
}
}
}
}
|
|