pat 1001. A+B Format (20)
来源:互联网 发布:淘宝退款流程手机 编辑:程序博客网 时间:2024/06/06 13:14
简单题
#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的情况忘记了
阅读全文
0 0
- PAT A 1001. A+B Format (20)
- PAT-A-1001. A+B Format (20)
- PAT A 1001. A+B Format (20)
- PAT-A 1001. A+B Format (20)
- PAT-A 1001. A+B Format (20)
- Pat(A) 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]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 1001. A+B Format (20)
- PAT 1001. A+B Format (20)
- Shell流程控制
- 独家 | 数据分析@爱可可-爱生活是否在用机器学习算法运营微博
- 用GAN还原语义标注图!还能手动改细节(附论文、代码)
- 近期活动盘点:大数据自杀风险感知讲座、智能制造讲座、数据法学研讨会、海外学者短期讲学(12.7-12.20)
- C# winform webbrowser如何指定内核为高版本
- pat 1001. A+B Format (20)
- 写给程序猿的把妹指南:概述篇
- 【第1135期】CSS简史
- mysql数据库软件navicat设置外键报错处理
- 【广告】前端架构师独家揭秘:月薪30k难吗?
- 6 大主流 Web 框架优缺点对比
- Android Dex文件结构
- 6 大主流 Web 框架优缺点对比
- Element 中的 AT 可访问性