# 拆分数位后四位数字的最小和
import java.util.Arrays;
import java.util.HashMap;
/**
* @author yagol
* @date 下午10:31
* @desc the description of this class
**/
class Solution5984 {
public static void main(String[] args) {
System.out.println(new Solution5984().minimumSum(4009));
}
public int minimumSum(int num) {
char[] data = String.valueOf(num).toCharArray();
Arrays.sort(data);
String num1 = "", num2 = "";
for (int i = 0; i < data.length; i += 2) {
num1 += data[i];
num2 += data[i + 1];
}
System.out.println(num1 + " " + num2);
int data1 = Integer.valueOf(num1);
int data2 = Integer.valueOf(num2);
return data1+data2;
}
}
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
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