forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproString1.java
More file actions
48 lines (32 loc) · 1.11 KB
/
proString1.java
File metadata and controls
48 lines (32 loc) · 1.11 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
public class proString1 {
public static String solution(String s) {
String answer = "";
String A[] = s.split(" ");
int length = A.length;
int count =0;
for(String a: A)
{
count ++;
for(int i =0; i<a.length(); i++)
{
if(i==0 && (int) a.charAt(i) > 91)
answer += (char)((int) a.charAt(i) -32);
else if(i != 0 && ((int)a.charAt(i) > 64 && (int)a.charAt(i) < 91 ))
answer += (char)((int) a.charAt(i) + 32);
else
answer += a.charAt(i);
}
if(count == length)
break;
answer += " ";
}
//32차이, Z가 90
if (s.substring(s.length() - 1, s.length()).equals(" ")) {
answer += " ";}
return answer;
}
public static void main(String[] args) {
String str= "3for the LicHking";
System.out.println(solution(str));
}
}