package text;
import java.util.Scanner;
public class text1 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入要打印几行的实心菱形:");
int n=sc.nextInt(); //n为菱形上半部分的行数
for(int i=0;i<n;i++) {
for(int j=i+1;j<n;j++) {
System.out.print(" ");
}
for(int j=0;j<2*i+1;j++) {
if(i==n-1 && j==n-1 )
{
System.out.print(" ");
}
else
{
System.out.print("*");
System.out.print(" ");
}
}
System.out.println();
}
for(int i=n-2;i>=0;i--) {
for(int j=i+1;j<n;j++) {
System.out.print(" ");
}
for(int j=0;j<2*i+1;j++) {
System.out.print("*");
System.out.print(" ");
}
System.out.println();
}
}
}
运行结果: