Skip to content

Commit ab7b185

Browse files
authored
Create RepeatTriangle.java
1 parent 6ea0cba commit ab7b185

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

RepeatTriangle.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import java.util.*;
2+
3+
4+
class Solution {
5+
6+
public static void print(int n) {
7+
int line,space,i,j;
8+
int p=n;
9+
for(line=0;line<=n;line++){
10+
for(space=0;space<line;space++)
11+
System.out.print(" ");
12+
int a=65;
13+
for(i=0;i<p;i++){
14+
System.out.print((char)a);
15+
a++;
16+
}
17+
int b=65+n-line-1;
18+
for(j=0;j<p;j++){
19+
System.out.print((char)b);
20+
b--;
21+
}
22+
System.out.println();
23+
p--;
24+
}
25+
26+
//Write your code here
27+
28+
}
29+
}
30+
31+
32+
class RepeatTriangle{
33+
public static void main(String[] args) {
34+
Scanner sc=new Scanner(System.in);
35+
Solution s=new Solution();
36+
int row=sc.nextInt();
37+
s.print(row);
38+
}
39+
}

0 commit comments

Comments
 (0)