AC代码

#include <cstdio>
#include <algorithm> using namespace std; const int maxn = 11;
int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
long long a, b;
scanf("%lld %lld", &a, &b);
long long sum = a + b;
int ans[maxn];
int num = 0;
if(sum < 0) {
printf("-");
sum = -sum;
}
do {
ans[num++] = sum % 10;
sum /= 10;
} while(sum != 0);
//reverse(ans, ans+num);2
// for(int i = num - 1; i >= 0; i--) printf("%d", ans[i]);
for(int i = num - 1, t = 1; i >= 0; i--,t++) {
printf("%d", ans[i]);
if(i > 0 && i % 3 == 0) {
printf(",");
}
t++;
}
return 0;
}

PAT A1001 A+B Format (20 分)的更多相关文章

  1. PAT 1001 A+B Format (20分) to_string()

    题目 Calculate a+b and output the sum in standard format -- that is, the digits must be separated into ...

  2. PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...

  3. PAT乙级:1088 三人行 (20分)

    PAT乙级:1088 三人行 (20分) 题干 子曰:"三人行,必有我师焉.择其善者而从之,其不善者而改之." 本题给定甲.乙.丙三个人的能力值关系为:甲的能力值确定是 2 位正整 ...

  4. PAT乙级:1064 朋友数 (20分)

    PAT乙级:1064 朋友数 (20分) 题干 如果两个整数各位数字的和是一样的,则被称为是"朋友数",而那个公共的和就是它们的"朋友证号".例如 123 和 ...

  5. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  6. [PAT] 1140 Look-and-say Sequence(20 分)

    1140 Look-and-say Sequence(20 分)Look-and-say sequence is a sequence of integers as the following: D, ...

  7. pat 1132 Cut Integer(20 分)

    1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...

  8. pat 1100 Mars Numbers(20 分)

    1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...

  9. pat 1108 Finding Average(20 分)

    1108 Finding Average(20 分) The basic task is simple: given N real numbers, you are supposed to calcu ...

随机推荐

  1. P2699 【数学1】小浩的幂次运算

    原题链接 https://www.luogu.org/problemnew/show/P2699 P2699 [数学1]小浩的幂次运算 首先第一眼看这个题就知道要暴力枚举w^i 看是否在区间[l,r] ...

  2. HDU6513/CCPC2017--A Secret(KMP)

    A Secret Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 256000/256000 K (Java/Others)Total ...

  3. mysql与Oracle的区别:

    1.  Oracle是大型数据库而Mysql是中小型数据库,Oracle市场占有率达40%,Mysql只有20%左右,同时Mysql是开源的而Oracle价格非常高. 2. Oracle支持大并发,大 ...

  4. GDB之常见错误

    1. dl-debug.c:74: No such file or directory. 如上图,当使用 gdb 调试执行 r 时,会出现如上打印. 解决方法如下: apt-get install e ...

  5. Python 串口通讯

    摘要: pyserial module: https://github.com/tbusf/pyserial Python使用pyserial进行串口通信:http://blog.csdn.net/l ...

  6. docker 用nginx 部署 node应用

    1.查询镜像 # 1.查询镜像. docker search nginx  2.拉取指定的镜像 # 2.拉取指定的镜像 docker pull nginx 3.下载完成后终端查看 # 3.下载完成后终 ...

  7. Hbuilder用自有证书打包 ios App上架AppStore流程

    最近在用Hbuilder做跨平台开发,经过一番研究终于在苹果商店上架成功了一款产品!这款产品就很简单,直接用hbuilder打包好,然后上传到商店即可.这里参照ios app提交应用商店 这篇文章结合 ...

  8. JAVA类定义的修饰

    命名类的访问权限public.protected.friendly,private 这四个的权限, 作用域: 当前(父,超)类: 同一Package: 派生(子)类: 其他Package: publi ...

  9. 2.1 Go语言基础之运算符

    运算符用于在程序运行时执行数学或逻辑运算. 一.运算符 Go 语言内置的运算符有: 1. 算术运算符 2. 关系运算符 3. 逻辑运算符 4. 位运算符 5. 赋值运算符 1.1 算数运算符 运算符 ...

  10. React Native 常用第三方组件

    React-Native-Elements 一组开发RN的UI工具包(强烈推荐)