題目鏈接
我的題解
#include <stdio.h>
#include <cstdlib>
int main(){
int a,b,res;
while (scanf("%d%d",&a,&b)!=EOF){
res=a+b;
int abst=abs(res);
if(res<0)
printf("-");
if(abst/1000000!=0) {
printf("%d,", abst / 1000000);
abst%=1000000;
printf("%03d,", abst / 1000);
printf("%03d\n", abst % 1000);
} else if(abst/1000!=0){
printf("%d,", abst / 1000);
printf("%03d\n", abst % 1000);
} else{
printf("%d\n",abst%1000);-
}
}
return 0;
}
研究了一下python版題解
#python
//灰灰考研@一航
a,b = map(int,input().split())
print(format(a+b,','))
簡潔的驚人啊。
format()格式化數字
str.format()
map函數
用于處理一個列表里的元素,接受函數和列表作為參數,然后返回函數處理之后的新列表
遞歸式學習的懵逼小熊貓新的一年要加油啦