pat甲级打卡-1001 A+B Format
作者:互联网
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int res=a+b;
string s=to_string(res);
int cnt=1;
for(int i=s.size()-1;i>=0;i--){
if(cnt%3==0 && i-1>=0 &&s[i-1]!='-'){
s=s.substr(0,i)+","+s.substr(i);
// i--;
}
cnt++;
}
cout<<s;
return 0;
}
标签:cnt,pat,string,int,res,substr,&&,打卡,1001 来源: https://www.cnblogs.com/rabbithacker/p/16154666.html