【PAT Advanced Level】1001. A+B Format (20)
2013-09-28 21:26
519 查看
一开始用了locale,但是提交显示段错误,然后就用了传统方法,转化为字符串处理。
#include <iostream> #include <string> #include <sstream> using namespace std; int main() { int a,b; cin>>a>>b; int c = a + b; stringstream strStream; strStream<<c; //int转string的方法! string s = strStream.str(); for(int i = s.size() - 3; i > 0 && s[i - 1] != '-'; i -= 3) s.insert(i, ","); cout<<s<<endl; }
相关文章推荐
- PAT(Advanced level) 1001 A+B Format(20)
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- PAT (Advanced Level) Practise - 1001 A+B Format (20)
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- PAT (Advanced Level) Practise 1001 A+B Format (20)
- 【PAT】【Advanced Level】1001. A+B Format (20)
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- PAT(Advanced Level)1001. A+B Format (20)
- 编程题目:PAT(Advanced Level) Practice 1001. A+B Format (20)
- PAT-PAT (Advanced Level) Practise 1001. A+B Format (20) 【二星级】
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- 浙大PAT (Advanced Level) Practise 1001 A+B Format (20)
- PAT-PAT (Advanced Level) Practise 1001. A+B Format (20) 【二星级】
- PAT (Advanced Level) Practise 1001 A+B Format (20)
- PAT (Advanced Level) Practise 1001 A+B Format (20)
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- PAT (Advanced Level) Practise 1001 A+B Format
- 浙大 PAT Advanced level 1001. A+B Format
- PAT (Advanced Level) 1001. A+B Format (20)