我的代码:
#include<iostream>
using namespace std;
int main(){
int a,b; cin>>a>>b;
string s= to_string(a+b);
int length = s.length();
for (int i = 0; i < length ; ++i) {
cout<<s[i];
if(s[0] != '-'){
if( (length-1-i)%3==0 && i != length-1)
cout<<',';
}
else{
if((length-1-i)%3==0 && i!= length-1 && i!=0)
cout<<',';
}
}
}
主要考察对下标的观察。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。