PAT (Advanced Level) 1001. A+B Format (20)
简单题。
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std; int a,b,tot,cnt;
int u[];
char ans[]; int main()
{
while(~scanf("%d%d",&a,&b))
{
a=a+b;
if(a==)
{
printf("0\n");
continue;
}
int tmp=abs(a);
tot=,cnt=;
while(tmp) u[tot++]=tmp%,tmp=tmp/; for(int i=; i<tot; i++)
{
ans[cnt++]=u[i]+'';
if((i+)%==&&tot-i!=) ans[cnt++]=',';
}
if(a<) ans[cnt++]='-';
for(int i=cnt-; i>=; i--) printf("%c",ans[i]);
printf("\n");
}
return ;
}
PAT (Advanced Level) 1001. A+B Format (20)的更多相关文章
- PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642
PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...
- PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642
PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...
- PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642
PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...
- PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642
PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642 题目描述: A reversible prime in any n ...
- PTA (Advanced Level) 1001 A+B Format
1001 A+B Format Calculate a+b and output the sum in standard format -- that is, the digits must be s ...
- PAT (Advanced Level) Practise - 1096. Consecutive Factors (20)
http://www.patest.cn/contests/pat-a-practise/1096 Among all the factors of a positive integer N, the ...
- PAT (Advanced Level) Practice 1152 Google Recruitment (20 分)
In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the p ...
- PAT (Advanced Level) 1054. The Dominant Color (20)
简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #inc ...
- PAT (Advanced Level) 1027. Colors in Mars (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...
随机推荐
- 今天遇到了隐藏顶部菜单栏(top bar)的菜鸟问题,解决了。
self.navigationController.navigationBarHidden = YES; http://stackoverflow.com/questions/3397381/hide ...
- C#常用集合的使用
大多数集合都在System.Collections,System.Collections.Generic两个命名空间.其中System.Collections.Generic专门用于泛型集合. 针对特 ...
- groupbox 下的datagridview的列标题字体修改混乱
groupbox 下的datagridview的列标题字体修改混乱
- iptables基础知识
iptables防火墙可以用于创建过滤(filter)与NAT规则.所有Linux发行版都能使用iptables,因此理解如何配置 iptables将会帮助你更有效地管理Linux防火墙.如果你是第一 ...
- ExceL转PDF
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Excel = ...
- C++函数后面的throw()
看CImage函数实现的时候发现了这么个东东 inline HBITMAP CImage::Detach() throw() 它是函数提供者和使用者的一种君子协定,标明该函数不抛出任何异常. 之所以 ...
- phpmyadmin导出数据中文乱码问题
phpMyAdmin版本是2.9.1.1 用phpMyAdmin备份数据库,导出来后,在本地用sqlyog还原的时候,出现如下错误:Error occured at:2009-03-03 10:09: ...
- Facade ——为子系统的一组接口提供一致界面
Façade模式提供了子系统一组接口的一致封装特性,如下图所示: 如图所示,OperationWrapper的实现依赖SubSystem1,2等的Operation操作.但用户调用OperationW ...
- Photos FrameWork 续
1. Model PHAsset .PHAssetCollection.PHCollectionList 是Photos框架中的模型类,PHAsset类模型是图片或者视频文件数据:PHAssetCol ...
- java断点
第一步: 用firefox运行程序,当点击保存,提示保存失败后,启动firebug 通过请求找到addNew.ezt出现错误,在eztnews.xml里通过ctrl+F查找找到请求执行的类和方法 找到 ...