标签:
import java.util.Scanner;
public class text {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("请输入一个等腰三角形的高:");
int height = scan.nextInt();
for (int j = 1; j <= height; j++) {
for (int i = 0; i < height - j; i++) {
System.out.print("0");
}
for (int i = 0; i < (2 * j - 1); i++) {
System.out.print("*");
}
System.out.println();
}
}
}
//求一个等边三角形的*
import java.util.Scanner;
public class P7 {
public static void main(String[] args) {
System.out.println("请输入一个三角形的高:");
Scanner scanner=new Scanner(System.in);
int number=scanner.nextInt();
for(int i=1;i<number;i++){
for(int space=1;space<=number-i-1;space++){
System.out.print(" ");
}
for(int star=1;star<=i;star++){
System.out.print("*"+" ");
}
System.out.println("");
}
}
}
标签:
原文地址:http://www.cnblogs.com/smile-zcc/p/5554903.html