-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNrotateString.java
More file actions
48 lines (43 loc) · 1.09 KB
/
NrotateString.java
File metadata and controls
48 lines (43 loc) · 1.09 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
import java.util.Scanner;
public class NrotateString {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String c = sc.nextLine();
String s2="";
// int i=0;
// int j=c.length()-1;
char[] s=c.toCharArray();
System.out.println("enter the no of roatation");
int n=sc.nextInt();
for (int q = 0; q <= n; q++) {
if(q<=n){
for (int i=0; i<s.length; i++){
for (int j = s.length-1; j >=0; j--) {
char t=s[i];
s[i]=s[j];
s[j]=t;
// s2 = s2 + s[s.length - 1 - i];
}
}
}
}
for (int i = 0; i < c.length(); i++) {
s2 = s2 + s[s.length - 1 - i];
}
// if(q<=n){
// while(i<j){
// char t=s[i];
// s[i]=s[j];
// s[j]=t;
// i++;
// j--;
// }
// }
// }
System.out.println(s2);
System.out.println();
for (int k = 0; k < s.length; k++) {
System.out.println(s[k]);
}
}
}