-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatternPrinting25.java
More file actions
34 lines (32 loc) · 1.11 KB
/
patternPrinting25.java
File metadata and controls
34 lines (32 loc) · 1.11 KB
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.Scanner;
public class patternPrinting25 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Please enter the value: ");
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if ((i+j)%2 == 0) {
System.out.print(1+ " ");
} else {
System.out.print(0+ " ");
}
// if(i%2 == 1) {
// if (j%2 ==1) {
// System.out.print(1+ " ");
// } else {
// System.out.println(0+ " ");
// } else {
// if (j%2 == 0) {
// System.out.println(1+ " ");
// } else {
// System.out.println(0+ " ");
// }
// }
// }
// System.out.print("* ");
}
System.out.println();
}
}
}