public class NestedLoop {
public static void main(String args[]) {
int i = 1;
while (i <= 6) {
int j = 6;
while (j >= i) {
System.out.print(j-- + " ");
}
i++;
System.out.println();
}
}
}
咁樣叫唔叫nested loop?
定係要咁樣??
public class NestedLoop {
public static void main(String args[]) {
for (int i = 1; i <= 6; i++) {
for (int j = 6; j >= i; j--) {
System.out.print(j + " ");
}
System.out.println();
}
}
}
[ Last edited by kalok914 on 6-1-2005 at 06:17 AM ]