PAT刷题
2015-12-25 18:38
316 查看
1001. A+B Format(20)
#include <cmath> #include <cstdio> #include <iostream> using namespace std; char str[100]; int main(){ // freopen("I-in.txt", "r", stdin); int a, b; scanf("%d%d", &a, &b); int c = a + b; int flag = 0; if(c < 0) flag = 1; int pos = 1; int tmp = abs(c); while(tmp){ if(pos%4 == 0)str[pos++] = ','; str[pos++] = '0' + tmp % 10; tmp /= 10; } if(flag) printf("-"); for(int i = pos - 1; i >= 1; i--) printf("%c", str[i]); if(!c) printf("0"); printf("\n"); return 0; }
相关文章推荐
- selenium2等待元素加载
- Kubernetes 之部署 cassandra + solr(datastax)解析
- 从一个案例看PL/SQL代码片的编译与运行
- 静态页面的抓取(学习简单爬虫)
- Swift类与结构、存储属性、计算属性、函数与方法、附属脚本等
- Git使用
- PAT刷题
- 博客园中前辈技术总结会不会过期
- 宏定义
- Oracle V$SESSION详解
- C语言随笔
- CI控制器调用内部方法并加载对应模板的做法
- 大白话系列之C#委托与事件讲解(二)
- 实现SVN与WEB同步解决方案(转)
- 常用命令
- 是否创建数据库判断以及建表
- Android如何获得系统(system)权限
- Pyqtdeploy Complie Win32 Version PyQtWin32静态编译记录
- Python Network Programming(6)---Socket网络编程总结
- 设备驱动简介