public static void print4(int n) {
for (int i = 1;i <= 2 ;i++ ) { //控制两层圆
for (int j = 0; j < 4*n ;j+=2) {
if (i==1) {
for ( int k = 0;k < 2*n ;k++ ) {
System.out.print(" ");
}
}
for (int k = 0;k < 4*n ;k++ ) { //画圆
if ((2*n-k)*(2*n-k)+(2*n-j)*(2*n-j) <= 4*n*n )
System.out.print("*");
else
System.out.print(" ");
}
if (i == 2) {
for (int k = 0;k < 4*n ;k++ ) { //画圆
if ((2*n-k)*(2*n-k)+(2*n-j)*(2*n-j) <= 4*n*n )
System.out.print("*");
else
System.out.print(" ");
}
}
System.out.println();
}
}
for (int i = 0;i < n;i++ ) { //画三角
for (int k = 0;k <4*n-i ;k++ ) {
System.out.print(" ");
}
for (int j = 0; j <= 2*i ; j++ ) {
System.out.print("*");
}
System.out.println();
}
}
|
|