【PAT甲级】1001 A+B Format (20 分)
题意:给两个整数a,b,计算a+b的值并每三位用逗号隔开输出(−1e6≤a,b≤1e6)
AAAAAccepted code:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int ans=a+b;
if(ans<){
cout<<"-";
ans=-ans;
}
int x=ans%;
int y=ans/;
int z=y%;
int yy=y/;
if(yy){
cout<<yy<<",";
if(z/)
cout<<z<<",";
else if(z/)
cout<<""<<z<<",";
else if(z)
cout<<""<<z<<",";
else
cout<<"000,";
if(x/)
cout<<x;
else if(x/)
cout<<""<<x;
else if(x)
cout<<""<<x;
else
cout<<"";
}
else if(z){
cout<<z<<",";
if(x/)
cout<<x;
else if(x/)
cout<<""<<x;
else if(x)
cout<<""<<x;
else
cout<<"";
}
else
cout<<x;
return ;
}
【PAT甲级】1001 A+B Format (20 分)的更多相关文章
- PAT甲级——1001 A+B Format (20分)
Calculate a+b and output the sum in standard format – that is, the digits must be separated into gro ...
- PAT 甲级 1001 A+B Format (20)(20 分)
1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...
- PAT 甲级1001 A+B Format (20)(C++ -思路)
1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...
- PAT甲级 1001. A+B Format (20)
题目原文: Calculate a + b and output the sum in standard format -- that is, the digits must be separated ...
- PAT Advanced 1001 A+B Format (20 分)
Calculate a+b and output the sum in standard format -- that is, the digits must be separated into gr ...
- 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甲级:1152 Google Recruitment (20分)
PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...
- PAT甲 1001. A+B Format (20) 2016-09-09 22:47 25人阅读 评论(0) 收藏
1001. A+B Format (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Calculate ...
- 【PAT】1001. A+B Format (20)
1001. A+B Format (20) Calculate a + b and output the sum in standard format -- that is, the digits m ...
- PAT甲级 1001 A+B Format
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 1001 A+B Format ( ...
随机推荐
- Dev-Cpp/Code::Block/MinGW下使用EasyX
众所周知,EasyX是个很香的东西,但EasyX目前只支持Visual Studio,那么如果要在MinGW(Dev-Cpp和Code::Block均使用这个编译器)上使用EasyX怎么办呢? 这篇文 ...
- (转载)Docker的boot2docker.iso镜像使用
原文路径:https://blog.csdn.net/jiangjingxuan/article/details/54908272#commentsedit 在Docker首次启动时需要下载的一个bo ...
- codeforces Make The Fence Great Again(dp)
题目链接:http://codeforces.com/contest/1221/problem/D 题目要求ai ! = ai-1,草纸上推理一下可以发现每一个栅栏可以升高的高度无非就是 +0,+1, ...
- Abp中打开错误信息输出
Abp默认是不向客户端输出错误日志的,导致有些内部报错既不能中断,也没有信息输出.此时打开日志输出开关即可.在xxModule类中PreInitialize()方法里 Configuration.Mo ...
- nfs 动态文件挂载读写权限设置
nfs 动态文件挂载读写权限设置 待办 ll 命令查看文件夹权限 参考设置共享文件夹https://www.linuxidc.com/Linux/2018-11/155331.htm
- pytorch数学运算与统计属性入门(非常易懂)
pytorch数学运算与统计属性入门1.Broadcasting (维度)自动扩展,具有以下两个重要特征:(1)expand (2)without copying data重点的核心实现功能是:(1) ...
- Vue 高德地图 路径规划 画点
CDN 方式 <!--引入高德地图JSAPI --> <script src="//webapi.amap.com/maps?v=1.4.13&key=您申请的ke ...
- Spring bean继承
Bean 定义继承 bean 定义可以包含很多的配置信息,包括构造函数的参数,属性值,容器的具体信息例如初始化方法,静态工厂方法名,等等. 子 bean 的定义继承父定义的配置数据.子定义可以根据需要 ...
- cordova的安装与配置
1.安装nodejs(自动包含npm) 2.在命令行中通过npm语句npm install -g cordova 安装cordova(如果提示网络连接失败,需要设置网络代理,搭理网址:npm conf ...
- C语言当中int,float,double,char这四个有什么区别?
区别在以下方面: 一.定义方面: 1.int为整数型,用于定义整数类型的数据 . 2.float为单精度浮点型,能准确到小数点后六位 . 3.double为双精度浮点型,能准确到小数点都十二位 . 4 ...