题意:给两个整数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 分)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. PAT甲级 1001. A+B Format (20)

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

  5. 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 ...

  6. 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 ...

  7. PAT甲级:1152 Google Recruitment (20分)

    PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...

  8. 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 ...

  9. 【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 ...

  10. PAT甲级 1001 A+B Format

    题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 1001 A+B Format ( ...

随机推荐

  1. Python记之薄暮笔记

    ——————————————————————————————接下来请欣赏与众不同的表演. Python打印所有的字符串时,都用引号将其括起. 有一些独特而有用的字符串表示方式. 可使用三引号表示很长的 ...

  2. xml配置文件中对于Shiro 权限管理filterChainDefinitions过滤器配置

    博客转载:http://blog.csdn.net/userrefister/article/details/47807075 /** * Shiro-1.2.2内置的FilterChain * @s ...

  3. 如何在Access中使用SQL语句

    如何在Access中使用SQL语句 创建,查询设计,弹出[显示表]窗口,点击[关闭]将该窗口关掉.这时软件会进入[设计]工具栏,我们点击工具栏左侧的[SQL视图].[SQL视图]默认选择的是[设计视图 ...

  4. Multisim 如何添加文本 如何编辑文本字体

    1.在Multisim中如何添加文本 方法1)Place -> Text 方法2)Ctrl+T 2.如何修改字体的大小及颜色

  5. redis哈希操作

    用户可以通过执行hset命令为哈希中的指定字段设置值: 127.0.0.1:6379> hset hash field value 根据给定的字段是否存在于散列中,hset命令的行为也会有所不同 ...

  6. 多核 CPU 和多个 CPU 有何区别?

    原文来自:http://www.solves.com.cn/it/yj/CPU/2019-06-24/1122.html 多核CPU和多CPU的区别主要在于性能和成本.多核CPU性能最好,但成本最高: ...

  7. xampp 配置多域名工程 解决 Access forbidden!

    XAMPP虚拟主机配置,多域名绑定访问本地站点 XAMPP有时候你需要一些顶级域名访问方式来访问你本地的项目也就是虚拟主机配置,这时候就需要配置虚拟主机,给你的目录绑定一个域名,实现多域名绑定访问. ...

  8. 使用Spring框架整合Java Mail

    我的博客名为黑客之谜,今天演示的案例中会出现我的邮箱,还不赶紧收藏!我现在是小白,但是随着时间的流逝,我会逐渐向大神走进,所以,喜欢我的,或者喜欢大神的,点一波关注吧!顺便说一下,双十二快到了,有什么 ...

  9. 【设计模式】UML类图及Java的类之间的关系

    UML类图展示 设计模式中的对象关系 关联和依赖的对比 依赖关系 虚线箭头 依赖是a类成员方法中有b类的属性,动物新陈代谢方法中有水和空气的属性,只有调这个方法的时候,才可能临时用一下 关联关系 实线 ...

  10. Web基础了解版07-EL表达式-运算符-11个隐式对象

    EL EL(Expression Language)是JSP内置的表达式语言,用以访问页面的上下文以及不同作用域中的对象 ,取得对象属性的值,或执行简单的运算或判断操作.EL在得到某个数据时,会自动进 ...