-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathstringpattern2.java
More file actions
35 lines (29 loc) · 866 Bytes
/
Copy pathstringpattern2.java
File metadata and controls
35 lines (29 loc) · 866 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
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
class StringPattern2
{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String str = s.nextLine(); // Input the String.
String rev = "";
int l = str.length();
int n = s.nextInt(); // Input no. of times the value to be printed.
char ch;
for (int i=0; i<l; i++) { // Loop to reverse the string.
ch= str.charAt(i);
rev= ch+rev;
}
for(int i=0;i<n;i++) { // Loop to print rows.
for(int j=0;j<l;j++) { // Loop to print the string
System.out.print(rev.charAt(j) + " ");
}
System.out.println();
}
}
}
// Sample Input :- HOUSE
// 4
// Output :-
// E S U O H
// E S U O H
// E S U O H
// E S U O H