public class list4_23 {
public static void main(String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int select=1;
System.out.println("숫자를 입력하세요.");
while(true){
try{
String line =reader.readLine();
select = Integer.parseInt(line);
break;
}catch(IOException e){
System.out.println(e);
}catch(NumberFormatException e){
System.out.println("入力が間違いました。再びやり直してください。");
}
}
for(int i=1;i<=select;i++){
for(int j=select;j>=i+1;j--){
System.out.print(" ");
}
for(int j=1;j<=(2*(i-1)+1);j++){
System.out.print("*");
}
System.out.println("");
}
}
}
'Web Dev > JAVA' 카테고리의 다른 글
자바연수)7-21 문제 개별코딩 (0) | 2015.04.23 |
---|---|
JAVA String 클래스 생성자와 메서드 정리 (0) | 2015.04.22 |
자바연수) chapter4 마지막문제 (0) | 2015.04.21 |
자바연수) chapter4 test2 (0) | 2015.04.21 |
자바연수) chapter4 test1 (0) | 2015.04.21 |