2012年大一学C语言时做的空心菱形
//package cn.tedu;
import java.util.Scanner;
public class dmeo {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for ( int i=1;i<=n;i++)
{ for ( int k=1;k<=(n-i);k++)
{ System.out.print(" "); }
for ( int j=1;j<=2*i-1;j++)
{ if(j==1||j==2*i-1) {System.out.print("* ");}
else{System.out.print(" ");}}
System.out.println();
}
for ( int i=1;i<=n-1;i++)
{ for ( int k=1;k<=i;k++)
{ System.out.print(" "); }
for ( int j=1;j<=2*(n-i)-1;j++)
{ if(j==1||j==2*(n-i)-1) {System.out.print("* ");}
else{System.out.print(" ");} }
System.out.println();
}
}
}