【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 ( ...
随机推荐
- Makefile中的wildcard/notdir/patsubst
在Makefile规则中,通配符会被自动展开. 但在变量的定义和函数引用时,通配符将失效.这种情况下如果需要通配符有效,就需要使用函数“wildcard”,它的用法是:$(wildcard PATTE ...
- STA 开篇
时序分析=动态时序分析+静态时序分析 动态时序分析简单讲就是gate-level simulation,仿真对象是netlist+sdf,通过SDF反标,得到gate跟net的delay,通过输入大量 ...
- Wx-mpvue开发小程序
一.准备 安装Node 安装vue-cli ( npm install --global vue-cli ) 二.创建 初始化项目 ( vue init mpvue/mpvue-quickstart ...
- maven基础学习篇
一.Maven的两大核心功能:依赖管理(主要是jar包的管理) 和 一键构建 1.依赖管理:maven项目所需要的jar包全部放在仓库中,项目只放置jar包的坐标,所要用到的jar包都从仓库中获 ...
- 关于Spring+mybatis使用@Transactional注解事物没有生效的问题
控制台日志信息: was not registered for synchronization because synchronization is not active JDBC Connectio ...
- 学会C#可以做什么
C#基于.NET Framework 和 .NET CORE平台 Client/Server 客户端/服务端 windows桌面应用程序 winform 2D WPF 3D Browser/Se ...
- 理解ASP.NET Core验证模型 Claim, ClaimsIdentity, ClaimsPrincipal
Claim, ClaimsIdentity, ClaimsPrincipal: Claim:姓名:xxx,领证日期:xxx ClaimsIdentity:身份证/驾照 ClaimsPrincipal: ...
- 三大查找算法(Java实现)
三大查找算法 1.二分查找(Binary Search) public class BinarySearch { public static void main(String[] args) { in ...
- JavaScript可枚举的属性
/* 把P中的可枚举属性复制到o中,并返回o中 如果o和p中含有同名的属性,则覆盖O中的属性 这个函数并不处理getter和setter以及复制属性 */ function extend(o,p){ ...
- springboot去除内嵌tomcat和打包在tomcat中运行需要做的步骤
去除内嵌tomcat和添加jsp依赖 去除内嵌tomcat 在springboot启动依赖中去除内嵌tomcat <dependency> <groupId>org.sprin ...