1001. A+B Format
Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).
Input
Each input file contains one test case. Each case contains a pair of integers a and b where -1000000 <= a, b <= 1000000. The numbers are separated by a space.
Output
For each test case, you should output the sum of a and b in one line. The sum must be written in the standard format.
Sample Input
-1000000 9
Sample Output
-999,991
程序代码:*
#include<stdio.h>
int main()
{
int a,b,sum;
scanf("%d%d",&a,&b);
sum=a+b;
if(sum<0)
printf("-");
if(abs(sum)<1000)
printf("%d",abs(sum));
if(abs(sum)>=1000&abs(sum)<1000000)
printf("%d,%03d",abs(sum)/1000,abs(sum)%1000);
if(abs(sum)>=1000000&abs(sum)<=2000000)
printf("%d,%03d,%03d",abs(sum)/1000000,abs(sum)/1000%1000,abs(sum)%1000);
return 0;
}
1001. A+B Format的更多相关文章
- 1001.A+B Format (20)代码自查(补足版)
1001.A+B Format (20)代码自查(补足版) 谢谢畅畅酱的提醒,发现了代码中的不足,把变量名更改成更合理的名字,并且把注释也换成英文啦! 栋哥提供的代码自查的方式也帮助了我发现很多代码中 ...
- PAT甲级 1001 A+B Format
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 1001 A+B Format ( ...
- 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 ...
- 1001.A+B Format(10)
1001.A+B Format(20) github链接:[example link](https://github.com/wgc12/object-oriented 1.对题目的理解: 首先这道题 ...
- PTA (Advanced Level) 1001 A+B Format
1001 A+B Format Calculate a+b and output the sum in standard format -- that is, the digits must be s ...
- PAT 1001. A+B Format 解题
GitHub PDF 1001. A+B Format (20) Calculate a + b and output the sum in standard format -- that is, t ...
- 1001 A+B Format (20 分)
1001 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits mu ...
- 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 ...
- 关于‘1001.A+B Format (20)’的解题报告
1001.A+B Format(20) 首先要感谢一下指导我github上传问题的小伙伴们,捣腾了一整天我终于摸到了一点门路,真的谢谢你们. 小豪的github 问题描述: Calculate a + ...
随机推荐
- VB ListBox 添加横向滚动条
Private Declare Function SendMessage Lib "user32 " Alias "SendMessageA" (ByVal h ...
- WPF Image Binding Uri Source 失败解决办法
在ListView 的ListItem里动态绑定Image. 首先代码写的是没有问题的.但最后运行却无法显示图片.先看代码: 1. XAML部分 代码如下: <ListView x:Name=& ...
- H264帧内预测模式编号的编码过程
1 本文词汇约定 宏块:H264编码基本单元,16x16像素(或采样)构成 块: 由8x8像素(或采样)构成的单位 子块: 由4x4像素(或采样)构成的单位 2 帧内亮度预测模式 H264规范 ...
- TheFourthJavaText
在Java语言中,在一个类的内部静态方法是无法直接访问该类的非静态成员的,这一点和C++一致.比如下面的代码: import javax.swing.JOptionPane; public class ...
- 如何提高maven的下载速度:享受一下mvn时飞的感觉
找到 maven老家 conf/settings.xml, 在<mirrors>标签内增加阿里云maven镜像 最终结果见下面: <mirrors> < ...
- maven GroupId 和ArtifactId的含义
GroupID是项目组织唯一的标识符,实际对应Java的包的结构,是main目录里java的目录结构. ArtifactID就是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称.
- Oracle中sys和system用户的区别
1.数据库的启动需要以SYSDBA/SYSOPER身份登录. 2.如果在同一主机上使用IPC连接到数据库使用操作系统授权,登录任何一个用户都可以拥有as sysdba和as sysoper. 3.sy ...
- 在UE4中使用SVN作为source control工具
==========预先处理 1.到这个目录下 2.鼠标在空白处 按住shift键 同时右键 会多出一个 可以打开的cmd 3.输入命令,修改红线部分. me: 登陆svn地址的用户名, URL网址: ...
- 转:Android应用性能测试
Android用户也许会经常碰到以下的问题: 1)应用后台开着,手机很快没电了——应用耗电大 2)首次/非首次启动应用,进入应用特别慢——应用启动慢 3)应用使用过程中,越来越卡——CPU能力不足/内 ...
- django+celery+rabitmq
django 项目中的设置(proj代表项目目录) proj settings.py CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672/' ...