akvs

mail@pastecode.io avatar
unknown
java
7 months ago
831 B
4
Indexable
Never
import java.util.Scanner;

public class p1 {
    public static void main(String[] args) throws Exception {
    Scanner read_ip = new Scanner(System.in);
    int i, j, p, q, input;
    input = read_ip.nextInt();
    p = 1;
    q = input;
    for(i = 1; i <= input; i++)
    {
        for(j = 1; j <= input; j++)
        {
            if(j < p)
            {
                System.out.print("  ");
            }
            else if((j >= p) && (j <= q) || (i == j))
            {
                System.out.print("* ");
            }
            else if(j > q)
            {
                System.out.print("  ");
            }
        }
        if(i <= (input)/2)
        {
            q--;
            p++;
        }
        else
        {
            q++;
            p--;
        }
        System.out.println();
    } 
    }
}