-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString Builder.java
More file actions
42 lines (32 loc) · 878 Bytes
/
Copy pathString Builder.java
File metadata and controls
42 lines (32 loc) · 878 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
36
37
38
39
40
41
import java.util.Arrays;
import java.util.Scanner;
public class rogh{
public static void print(String str){
int x=0,y=0;
for(int i=0;i<str.length();i++){
if(str.charAt(i)=='w'||str.charAt(i)=='W')
x--;
else if(str.charAt(i)=='e'||str.charAt(i)=='E')
x++;
else if(str.charAt(i)=='n'||str.charAt(i)=='N')
y++;
else if(str.charAt(i)=='w'||str.charAt(i)=='W')
y--;
}
int X=x*x;
int Y=y*y;
System.out.println((int)Math.sqrt(X+Y));
}
public static void main(String args[]){
char arr[]={'a','b','c','d'};
String str2=new String("xyz");
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
StringBuilder sb=new StringBuilder();
print(str);
for(char ch='a';ch<='z';ch++){
sb.append(ch);
}
System.out.println(sb);
}
}