PAT (Advanced Level) 1001. A+B Format (20)

时间:2022-12-25 21:23:38

简单题。

#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)的更多相关文章

  1. PAT &lpar;Advanced Level&rpar; Practice 1046 Shortest Distance &lpar;20 分&rpar; 凌宸1642

    PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...

  2. PAT &lpar;Advanced Level&rpar; Practice 1042 Shuffling Machine &lpar;20 分&rpar; 凌宸1642

    PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...

  3. PAT &lpar;Advanced Level&rpar; Practice 1041 Be Unique &lpar;20 分&rpar; 凌宸1642

    PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...

  4. PAT &lpar;Advanced Level&rpar; Practice 1015 Reversible Primes &lpar;20 分&rpar; 凌宸1642

    PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642 题目描述: A reversible prime in any n ...

  5. PTA &lpar;Advanced Level&rpar; 1001 A&plus;B Format

    1001 A+B Format Calculate a+b and output the sum in standard format -- that is, the digits must be s ...

  6. PAT &lpar;Advanced Level&rpar; Practise - 1096&period; Consecutive Factors &lpar;20&rpar;

    http://www.patest.cn/contests/pat-a-practise/1096 Among all the factors of a positive integer N, the ...

  7. PAT &lpar;Advanced Level&rpar; Practice 1152 Google Recruitment &lpar;20 分&rpar;

    In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the p ...

  8. PAT &lpar;Advanced Level&rpar; 1054&period; The Dominant Color &lpar;20&rpar;

    简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #inc ...

  9. PAT &lpar;Advanced Level&rpar; 1027&period; Colors in Mars &lpar;20&rpar;

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. Java Web笔记之Servlet&lpar;1&rpar;

    今天在学习Servlet时,使用浏览器显示的网页效果与预期的有差异,仔细查找发现实<!DOCTYPE>声明的问题,截图如下: 代码如下: package secondServlet; im ...

  2. JavaScript encodeURI&lpar;&rpar;&comma; decodeURI&lpar;&rpar;&comma; encodeURIComponent&lpar;&rpar;&comma; decodeURIComponent&lpar;&rpar;

    URI:  Uniform Resource Identifier encodeURI() And decodeURI() The encodeURI() function is used to en ...

  3. 在定位中,如何清除已经设置好的bottom

    这个东西其实很简单,将bottom设auto,便可在设置top的值,那么具体的应用是什么?目前一个是用于全屏,二是用于输入框在手机端的下半屏(被输入发遮挡问题)? 例子如下 css代码: * { ma ...

  4. CentOS 6&period;4下通过YUM快速安装配置LAMP服务器&lpar;Apache&plus;PHP5&plus;MySQL&rpar;

    准备篇: 1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dp ...

  5. centOS学习part4&colon;安装配置vsftp

    0 上一章(http://www.cnblogs.com/souvenir/p/3875934.html)我们完成了对远程工具VNC的安装配置,接下来我们将安装另外一个常用工具:VSFTP. vsft ...

  6. uva540 Team Queue by sixleaves

    这道题目.主要是对队列的灵活应用.其实就是一道模拟题目,只要你洞察出题目的本质就十分简单.题目意思大体是有多组测试数据,每组的一开始是一个数字t,代表一共有多少的团队,接着是t行输入,每一行都由一个数 ...

  7. SolrCloud Hello Word

    Solr Cloud 设计出来的目的是使你的搜索服务具有更高的可用性,提高容错.容灾能力.下面我们在一台电脑上建立2个solr服务,作为一个solrCloud分片(shard),初步认识一下solrC ...

  8. reflow和repaint

    Web页面运行在各种各样的浏览器当中,浏览器载入.渲染页面的速度直接影响着用户体验 简单地说,页面渲染就是浏览器将html代码根据CSS定义的规则显示在浏览器窗口中的这个过程.先来大致了解一下浏览器都 ...

  9. EF 报【序列包含一个以上的元素】解决办法

    1.检查模型是否存在重复的字段,eg: public class AggregateRoot { public System.Guid Guid { get; set; } } public part ...

  10. 566&period; Reshape the Matrix

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...