PAT A1001 A+B Format (20 分)
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 分)的更多相关文章
- 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 ...
- 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 ...
- PAT乙级:1088 三人行 (20分)
PAT乙级:1088 三人行 (20分) 题干 子曰:"三人行,必有我师焉.择其善者而从之,其不善者而改之." 本题给定甲.乙.丙三个人的能力值关系为:甲的能力值确定是 2 位正整 ...
- PAT乙级:1064 朋友数 (20分)
PAT乙级:1064 朋友数 (20分) 题干 如果两个整数各位数字的和是一样的,则被称为是"朋友数",而那个公共的和就是它们的"朋友证号".例如 123 和 ...
- PAT 甲级 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- [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, ...
- 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 ...
- pat 1100 Mars Numbers(20 分)
1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...
- pat 1108 Finding Average(20 分)
1108 Finding Average(20 分) The basic task is simple: given N real numbers, you are supposed to calcu ...
随机推荐
- 堡垒机前戏——paramiko
提要:在写堡垒机之前,我们必须要了解paramiko这个第三方库.有关于python的第三方库的安装很简单,可以自行百度. 该模块基于SSH用于连接远程服务器并执行相关操作. SSHClient 用于 ...
- CodeForces–830B--模拟,树状数组||线段树
B. Cards Sorting time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- 浙江省赛C.Array in the Pocket(贪心+线段树)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4102 题意: 给出一个长度为n的数组,重排它们,让相同位置的数 ...
- 在docker容器中python3.5环境下使用DIGITS训练caffe模型
********* 此处使用的基础镜像为 nvcr.io/nvidia/digits:18.06,镜像大小为6.04GB,可从nvidia官方pull此镜像: 容器配置: CUDA:9.0 CUDNN ...
- 【软件工程】Alpha事后诸葛亮
链接部分 队名:女生都队 组长博客: 博客链接 作业博客:博客链接 参考邹欣老师的问题模板进行总结思考 一.设想和目标 1.我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的 ...
- [转]五步git操作搞定Github中fork的项目与原作者同步
命令如下: git clone xxx-fork.git git remote add xxx xxx.git git fetch xxx git merge xxx/master git push ...
- pytorch-mnist神经网络训练
在net.py里面构造网络,网络的结构为输入为28*28,第一层隐藏层的输出为300, 第二层输出的输出为100, 最后一层的输出层为10, net.py import torch from torc ...
- weight权重的属性
权重是把屏幕剩余空间按比例分配 控件使用0dp,则实际的宽度比就等于权重比 控件wrap_content,那么权重越大,位置占的越多,再小不过wrap_content 控件match_parent,那 ...
- C# 批处理制作静默安装程序包
使用批处理+WinRAR制作静默安装程序包 @echo 安装完窗口会自动关闭!!! @echo off start /wait Lync.exe /Install /Silent start /wai ...
- 九十四:CMS系统之cms后台登录限制
装饰器,验证当前session中是否存在定义的user_id,没有就重定向到登录页 from flask import session, redirect, url_forfrom functools ...