-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPattern7.java
49 lines (48 loc) · 879 Bytes
/
Pattern7.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.*;
public class Pattern7
{
public static void main(String[] args)
{
int i, j, rows;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of rows youy want to print: ");
rows = sc.nextInt();
for (i = rows; i >= 1; i--)
{
for (j = rows; j >= i; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
}
} public class Pattern8
{
public static void main(String[] args)
{
int rows=9; //number of rows to print
for (int i = 1; i <= rows; i++)
{
int num;
if(i%2 == 0)
{
num = 0;
for (int j = 1; j <= rows; j++)
{
System.out.print(num);
num = (num == 0)? 1 : 0;
}
}
else
{
num = 1;
for (int j = 1; j <= rows; j++)
{
System.out.print(num);
num = (num == 0)? 1 : 0;
}
}
System.out.println();
}
}
}