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. 记一次antlr错误:ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.2ANTLR

    场景:重构spark 2.1版本的sql语法.因此 需要使用antlr: 前期准备:idea安装了antlr插件(antlr的4.7.2版本) 因此在maven工程中添加了antlr的依赖: < ...

  2. mybatis集成spring

    1.为什么mybatis要去集成spring?===>简单来说就是为了让spring 来帮我们管理事务!!如果没有spring去帮助管理事务,那么需要我们自己去手动去维护事务,例如:发生异常需要 ...

  3. 【Mybatis】向MySql数据库插入千万记录 单条插入方式,用时 1h16m30s

    本例代码下载:https://files.cnblogs.com/files/xiandedanteng/InsertMillionComparison20191012.rar 相对于批量插入,这种方 ...

  4. [Java]使用Collections.Max,Min方法取集合类的最大最小值

    代码: package com.hy; import java.util.Arrays; import java.util.Collections; import java.util.List; pu ...

  5. 记一个微信支付-1错误JSAPI缺少参数app|get_brand_request:Fail

    最近公司要做一个H5小游戏里边涉及到微信公众号支付,中间摸爬滚打遇到了很多坑.记录一下,留待后人看. 我们来看一下这个方法 GetJsApiParameters 怎么样,看起来像不像输出了一个JSON ...

  6. 如何解决Sublime text中文乱码问题

    Sublime Text 2是一个非常不错的源代码及文本编辑器,但是不支持GB2312和GBK编码在很多情况下会非常麻烦.不过Sublime Package Control所以供的插件可以让Subli ...

  7. VC 实现程序只运行一个实例,并激活已运行的程序

    转载:http://blog.sina.com.cn/s/blog_4b44e1c00100bh69.html 进程的互斥运行:CreateMutex函数实现只运行一个程序实例 正常情况下,一个进程的 ...

  8. Swift开源parser

    https://www.prowidesoftware.com/products/core https://github.com/prowide/prowide-core-examples/blob/ ...

  9. 009-centos6.6 用户以及组操作

    1.查看用户所属组 id admin uid=500(admin) gid=500(admin) 组=500(admin) 2.查看用户信息 用户列表文件:cat /etc/passwd 查看系统中有 ...

  10. 一百一十七:CMS系统之注册页面对接短信验证码

    from flask import Blueprint, requestfrom exts import alidayufrom utils import restfulfrom utils.capt ...