public class Rhombus {
public static void main(String[] args) { printf(7);
}
public static void printf(int n) { int row = n; int col = n;
String arr[][] = new String[row][col]; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { arr[i][j] = \" \"; } }
int a = 0;
int b = col - 1;
for (int i = row / 2; i >= 0; i--) { arr[i][a++] = \"*\"; arr[i][b--] = \"*\"; }
int c = 1;
int d = col - 2;
for (int i = row / 2 + 1; i < row; i++) { arr[i][c++] = \"*\"; arr[i][d--] = \"*\"; }
for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { System.out.print(arr[i][j]); }
System.out.println(); } } }
因篇幅问题不能全部显示,请点此查看更多更全内容