markdown
#說明
經典星星樹
#操作流程
```
package startree;
import java.io.*;
public class startree {
public static void main (String args[]) throws IOException {
System.out.println("how height of the start tree?");
BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
String str =br.readLine();
int line =Integer.parseInt(str);
for(int i =1;i <= line;i++) {
for (int j=1; j<=line-i;j++)
System.out.print(" ");
for (int k=1;k<2*i;k++)
System.out.print("*");
System.out.println();
}
}
}
```
##菱形
```
package startree;
public class startree {
public static void main (String args[]) {
int line =4;
for(int i =1;i <= line;i++) {
for (int j=1; j<=line-i;j++)
System.out.print(" ");
for (int k=1;k<2*i;k++)
System.out.print("*");
System.out.println();
}
for(int ii =1;ii <= line;ii++) {
for (int kk=1;kk<2*ii;kk++)
System.out.print(" ");
for (int jj=1; jj<=2*(line-ii)-1;jj++)
System.out.print("*");
System.out.println();
}
}
}
```
留言
張貼留言