-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode1.java
More file actions
25 lines (24 loc) · 710 Bytes
/
code1.java
File metadata and controls
25 lines (24 loc) · 710 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.*;
class Demo {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter no. of rows : ");
int row = sc.nextInt();
int column = row + (row-1);
int mid = column/2;
for(int i=1; i<=row; i++) {
for(int j=0; j<mid; j++) {
System.out.print(" ");
}
for(int j=1; j<=column-(2*mid); j++) {
if(j%2 == 1) {
System.out.print(i+ " ");
}else {
System.out.print(" ");
}
}
System.out.println();
mid--;
}
}
}