Competitive Programming Solutions

GitHub
back to dashboard

B. Drawing 'X'

Codeforces - Contest #2 · limit: 1s · memory: 256MB · view on codeforces

input

5

output

\***/
*\*/*
**X**
*/*\*
/***\
Main.java
static void solve() {

        // Write your solution here
        int n = in.nextInt();
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i == n/2 && j == n/2)
                    out.print("X");
                else if(i == j)
                    out.print("\\");
                else if(j == n - 1 - i)
                    out.print("/");
                else
                    out.print("*");
            }
            out.println();
        }
    }