什么是for循环
// 练习1
int odd = 0;
int even = 0;
for (int i = 0; i <= 100; i++) {
if (i % 2 == 0) {
even += i;
} else {
odd += i;
}
}
System.out.println("奇数和为:" + odd + ",偶数和为:" + even);
// 练习2
for (int i = 1; i < 1000; i++) {
if (i % 5 == 0) {
System.out.print(i + " ");
if (i % 15 == 0) {
System.out.println();
}
}
}
// 练习3
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("\t" + j + "×" + i + "=" + i * j);
}
System.out.println();
}