采用to_string
用i%3==s.length()%3控制逗号输出
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
string ans=to_string(abs(a+b));
if(a+b<0)cout<<"-";
for(int i=0;i<ans.length();i++){
cout<<ans[i];
if((i+1)%3==ans.length()%3&&i+1!=ans.length())cout<<",";
}
}
最后
以上就是酷酷夏天最近收集整理的关于1001 A+B Format的全部内容,更多相关1001内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复