자바연수) chapter4 test2
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author aram.park
*/
public class list4_22 {
public static void main(String[] args) throws Exception {
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("数値を入力しましょう。");
String line = read.readLine();
int n = Integer.parseInt(line);
pira(n);
} catch (IOException e) {
System.out.println(e);
} catch (NumberFormatException e) {
System.out.println("数値を入力してください。再入力します。");
}
}
public static void pira(int n) {
for (int i = 0; i <= n; i++) {
for (int j = n; j > i; j--) {
System.out.print(" ");
}
for (int j = 1; j <= ((i - 1) * 2 + 1); j++) {
System.out.print("*");
}
System.out.println("");
}
}
}