我得到這個錯誤:進口java.util.Scanner中從未使用過
import java.util.scanner never used
我不知道我需要插入。
import java.util.Scanner;
public class Diamond {
public static void diamondOfAsterisks() {
for (int i = 1; i < 10; i += 2) {
for (int j = 0; j < 9 - i/2; j++)
System.out.print(" ");
for (int j = 0; j < i; j++)
System.out.print("*");
System.out.print("\n");
}
for (int i = 7; i > 0; i -= 2) {
for (int j = 0; j < 9 - i/2; j++)
System.out.print(" ");
for (int j = 0; j < i; j++)
System.out.print("*");
System.out.print("\n");
}
}
}
謝謝,這有幫助。 – Mike 2011-03-07 20:32:32