更新
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import java.util.*;
|
||||
|
||||
public class P2969 {
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
int n = in.nextInt();
|
||||
for (int i = 0; i < n; i++) {
|
||||
int stars = i <= n / 2 ? (2 * i + 1) : (2 * (n - i - 1) + 1);
|
||||
int spaces = (n - stars) / 2;
|
||||
StringBuilder row = new StringBuilder();
|
||||
for (int s = 0; s < spaces; s++) row.append(' ');
|
||||
for (int k = 0; k < stars; k++) row.append('*');
|
||||
System.out.println(row.toString());
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
Reference in New Issue
Block a user