-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFashionableX.java
More file actions
25 lines (24 loc) · 824 Bytes
/
FashionableX.java
File metadata and controls
25 lines (24 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Scanner;
public class FashionableX {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == j && i == n / 2) {
System.out.print("X");
} else if (i == j) {
System.out.print("\\");
} else if (i + j == n - 1) {
System.out.print("/");
} else if ((i < j && i + j < n - 1) || (i > j && i + j > n - 1)) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
scanner.close();
}
}