pat 1001. A+B Format (20)
2017-12-10 08:26
405 查看
简单题
但是在第一次写完之后有一个测试点没有过
因为a+b=0的情况忘记了
#include <iostream> #include <cstring> #include <stack> #include <cmath> using namespace std; int main(){ ios::sync_with_stdio(false); int a,b; cin>>a>>b; bool flag = false; int c = a+b; if(!c) cout<<c; stack<char>res; if(c<0){ flag = true; } c = c>0?c:-c; int tmp; int count = 0; while(c){ tmp=c%10; c /=10; res.push(tmp+'0'); count++; if(count==3 && c){ res.push(','); count =0; } } if(flag) cout<<'-'; while(res.size()){ cout<<res.top(); res.pop(); } return 0; }
但是在第一次写完之后有一个测试点没有过
因为a+b=0的情况忘记了
相关文章推荐
- [PAT]1001. A+B Format (20)
- PAT:1001. A+B Format (20)
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- PAT 1001. A+B Format (20)
- PAT-A 1001. A+B Format (20)
- PAT甲级 1001. A+B Format (20)
- PAT甲级 1001. A+B Format (20) 题目翻译与答案
- PAT 1001. A+B Format (20)
- PAT-1001 A+B Format (20)
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- [PAT]1001 A+B Format (20)
- 【PAT】1001.A+B Format (20)
- PAT1001. A+B Format (20)
- (PAT-A)1001. A+B Format (20)
- PAT甲级1001. A+B Format (20)
- PAT甲级1001. A+B Format (20)
- PAT 1001. A+B Format (20)
- 浙江大学PAT上机题解析之1001. A+B Format (20)
- PAT-PAT (Advanced Level) Practise 1001. A+B Format (20) 【二星级】
- [PAT甲级]1001. A+B Format (20)(AB和的标准输出)