Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
37 lines (30 loc) · 1.07 KB

File metadata and controls

37 lines (30 loc) · 1.07 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import java.util.*;
public class Main {
public static String str;
public static ArrayList<Character> result = new ArrayList<Character>();
public static int value = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
str = sc.next();
// 문자를 하나씩 확인하며
for (int i = 0; i < str.length(); i++) {
// 알파벳인 경우 결과 리스트에 삽입
if (Character.isLetter(str.charAt(i))) {
result.add(str.charAt(i));
}
// 숫자는 따로 더하기
else {
value += str.charAt(i) - '0';
}
}
// 알파벳을 오름차순으로 정렬
Collections.sort(result);
// 알파벳을 차례대로 출력
for (int i = 0; i < result.size(); i++) {
System.out.print(result.get(i));
}
// 숫자가 하나라도 존재하는 경우 가장 뒤에 출력
if (value != 0) System.out.print(value);
System.out.println();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.