Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- int spaces = 1;
- for (int i = 1; i < n; i++) {
- spaces += 2;
- }
- int currentZvezdo4ki = 1;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < (3 * n) - i; j++) {
- System.out.print(" ");
- }
- for (int j = 0; j < currentZvezdo4ki; j++) {
- System.out.print("*");
- }
- currentZvezdo4ki += 2;
- System.out.println();
- }
- currentZvezdo4ki = 1;
- int currentSpaces = spaces;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j <= spaces; j++) {
- System.out.print(" ");
- }
- for (int j = 0; j < currentZvezdo4ki; j++) {
- System.out.print('*');
- }
- for (int j = 0; j < currentSpaces; j++) {
- System.out.print(" ");
- }
- for (int j = 0; j < currentZvezdo4ki; j++) {
- System.out.print("*");
- }
- currentSpaces -= 2;
- currentZvezdo4ki += 2;
- spaces--;
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement