1: //输入正整数n,输出由n行n列星号字符组成的三角星图案。例如n=4:
2: /*
3: *
4: * *
5: * * *
6: * * * *
7: */
8: import java.io.*;
9: public class t2_8{
10: public static void main(String argv[]){
11: String strn = null;
12: BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
13: System.out.println("Please input n :");
14: try {
15: strn = in.readLine();
16: } catch (IOException e) {
17: // TODO 自动生成的 catch 块
18: e.printStackTrace();
19: }
20: int n = Integer.parseInt(strn);
21: char str[] = new char[n];
22: for(int i=1;i<=n;i++)
23: {
24: str[n-i] = '*';
25: strn = new String(str);
26: System.out.println(strn);
27: }
28: }
29: }