-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIncreasing_Isoscoles_pattern.txt
More file actions
74 lines (57 loc) · 1.42 KB
/
Copy pathIncreasing_Isoscoles_pattern.txt
File metadata and controls
74 lines (57 loc) · 1.42 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Code : Triangle of Numbers
Send Feedback
Print the following pattern for the given number of rows.
Pattern for N = 4
The dots represent spaces.
Input format :
Integer N (Total no. of rows)
Output format :
Pattern in N lines
Constraints :
0 <= N <= 50
Sample Input 1:
5
Sample Output 1:
1
232
34543
4567654
567898765
Sample Input 2:
4
Sample Output 2:
1
232
34543
4567654
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
/* Your class should be named Solution.
* Read input as specified in the question.
* Print output as specified in the question.
*/
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int i = 1;
while(i<=n){
int j = 1;
int x = i;
int y = 2*i -2;
while(j <= n+i-1){
if(j<=n-i){
System.out.print(" ");
}else if(j>n-i && j<=n){
System.out.print(x);
x = x+1;
}else if(j>n && j<=n+i-1){
System.out.print(y);
y = y-1;
}
j = j+1;
}
System.out.println();
i=i+1;
}
}
}