1个回答
展开全部
用java写了一个、你看看、 public class isoceles {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("请输入行数:");
int k=input.nextInt();
for (int i = 0; i <k; i++) {
for (int j = 1; j < k-i; j++) {
System.out.print(" ");
}
for (int j = i; j >=0 ; j--) {
System.out.print("* ");
}
System.out.println();
}
for (int i = k-1; i >0; i--) {
for (int j = 0; j < k-i; j++) {
System.out.print(" ");
}
for (int j = i-1; j >=0 ; j--) {
System.out.print("* ");
}
System.out.println();
}
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("请输入行数:");
int k=input.nextInt();
for (int i = 0; i <k; i++) {
for (int j = 1; j < k-i; j++) {
System.out.print(" ");
}
for (int j = i; j >=0 ; j--) {
System.out.print("* ");
}
System.out.println();
}
for (int i = k-1; i >0; i--) {
for (int j = 0; j < k-i; j++) {
System.out.print(" ");
}
for (int j = i-1; j >=0 ; j--) {
System.out.print("* ");
}
System.out.println();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询