import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String[] split = bufferedReader.readLine().split(" ");
int a = Integer.parseInt(split[0]);
int b = Integer.parseInt(split[1]);
bufferedReader.close();
Integer sum = a + b;
if (sum > -1000 && sum < 1000) {
System.out.println(sum);
}else {
String format = format(sum);
System.out.println(format);
}
}
private static String format(Integer sum){
StringBuilder stringBuilder = new StringBuilder();
String s = sum.toString();
boolean isNegative = (sum<0);
if(sum<0){
s = s.substring(1);
stringBuilder.append("-");
}
int length = s.length();
for (int i = 0;i<length;i++){
if((length-1-i)%3==0&&(i+1)!=length){
stringBuilder.append(s.charAt(i));
stringBuilder.append(",");
}else {
stringBuilder.append(s.charAt(i));
}
}
return stringBuilder.toString();
}
}
浙江大学PAT甲级(1001)题解(java)
最新推荐文章于 2023-04-06 22:36:37 发布