关于星阵的来看看啊
import java.util.Scanner;
public class Demo2_Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个整数");
String a = sc.nextLine();
try {
getXing(a);
} catch (Exception e) {
System.out.println("您输入的不是整数,请重新输入");
;
} finally {
}
}
public static void getXing(String m) {
for (int i = Integer.parseInt(m); i >= 0; i--) {
for (int j = 1; j <= i ; j++) {
System.out.print("*" + " ");
}
System.out.println();
}
}
}
|
|