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 + ...
随机推荐
- 在iOS9中 xcode7 网络请求 如图片请求不显示等
Application Transport Security has blocked a cleartext HTTP (http://) resource load since it is inse ...
- html 页面太长滚动时,固定页面菜单标签,或者导航标签的位置,fixed/stickUp the position
有时你曾经需要把页面上的某些东西当页面太长发滚动的时候保留置顶位置显示,或许你有别的实现方式,我这个仅供参考, 源代码: /*global $, jQuery, alert*/ (function ( ...
- 项目版本管理 github简介
git config user.email "c.wuliying@samsung.com"git config user.name "swportal" ** ...
- Qt对ini文件的读写
研究了以下Qt下ini文件的读写,不废话,上干货. 写入ini文件 WriteIni.cpp void WriteIni::writeSettings() { QSettings settings(& ...
- Debian7安装php5.5/5.6
### 1 添加源 echo "deb http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources ...
- javascript函数作用域实践
在es6之前,JavaScript是没有块级作用域的,只有函数作用域,也就是说是一个function里面定义的变量外面取不到的:而if for是条件判断的语句,不是函数,由于缺少块级作用域,所以条件中 ...
- Oracle数据库初探
一.安装oracle数据库 步骤:转载一个很不错的文档:http://www.linuxidc.com/Linux/2015-02/113222.htm 注意点:安装的时候会check相关依赖,有些可 ...
- java学习初体验之课后习题
import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { //打印Hel ...
- javaWEB总结(12):JSP页面的九个隐含对象
前言 jsp本质上是一个servlet,而在jsp中有九个不用声明就可以使用的对象,我们叫他隐含对象.本文基于上文所写,如有需要可查看上一篇文章javaWEB总结(11):JSP简介及原理. 打开上次 ...
- 使用MyBatis3时 selectOne 方法返回null的问题记录
不多废话,直接上干货. mapper配置: <resultMap type="User" id="usermap"> <result colu ...