-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoxandsnake.java
More file actions
34 lines (29 loc) · 932 Bytes
/
foxandsnake.java
File metadata and controls
34 lines (29 loc) · 932 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
26
27
28
29
30
31
32
33
34
import java.util.*;
public class foxandsnake {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int r = sc.nextInt();
int c = sc.nextInt();
for (int i = 1; i <= r; i++) {
if (i % 2 == 1) {
for (int j = 0; j < c; j++) {
System.out.print('#');
}
} else {
if ((i / 2) % 2 == 1) {
for (int k = 0; k < c - 1; k++) {
System.out.print('.');
}
System.out.print('#');
} else {
System.out.print('#');
for (int k = 0; k < c - 1; k++) {
System.out.print('.');
}
}
}
System.out.println();
}
sc.close();
}
}