PAT甲级 1001 A+B Format
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400
1001 A+B Format (20 分)
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 Specification:
Each input file contains one test case. Each case contains a pair of integers a and b where −106≤a,b≤106. The numbers are separated by a space.
Output Specification:
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
AC代码:
#include <iostream>
#include<cstdio>
using namespace std;
int main(int argc, char const *argv[])
{
int a, b;
cin >> a >> b; int c = a + b;
if (a + b < ) {
cout << "-";
c = -c;
}
if (c >= ) {
printf("%d,%03d,%03d\n", c / , c % / , c % ); } else if (c >= ) {
printf("%d,%03d\n", c / , c % );
} else {
printf("%d\n", c );
} return ;
}
PAT甲级 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 ...
- PAT甲级 1001. A+B Format (20)
题目原文: Calculate a + b and output the sum in standard format -- that is, the digits must be separated ...
- PAT 甲级 1001 A+B Format
https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 Calculate a + b and ou ...
- 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) 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 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甲级1001水题飘过
#include<iostream> using namespace std; int main(){ int a, b; while(scanf("%d%d", &a ...
随机推荐
- The threat to world
The threat to world 对世界贸易的威胁"> The rules-based system is in grave(严重的) danger 基于规则的体系岌岌可危 DO ...
- 蚂蚁金服ATEC城市峰会上海举行,三大发布迎接金融科技2019
2019年1月4日,蚂蚁金服ATEC城市峰会以“数字金融新原力(The New Force of Digital Finance)”为主题在上海举办.稠州银行副行长程杰.蚂蚁金服副总裁刘伟光.蚂蚁金服 ...
- Git Learning3 Eclipse Tools(未完成)
1.创建Git 操作:工程 右键 Team Share Project Git 完成创建 2.全局设置:Window->Preference->Git->Configuration- ...
- Cocos Creator学习五:触摸和重力传感响应事件
1.移动设备上主要涉及触摸响应事件以及重力传感响应事件的处理. 事件主要分两类: 针对节点事件处理的节点响应事件cc.Node.EventType(主要是触摸响应事件和鼠标响应事件): 针对全局系统事 ...
- MATLAB 符号变量表达式 + 方程求解
源代码见文末 部分源代码: % 符号变量 两种表达方式 a=sym('a'); class(a); syms b; b; % 符号常量 c=sym('); c; % 符号表达式 三种表达方式 f1=' ...
- ajax、axios、fetch之间的详细区别以及优缺点
1.jQuery ajax $.ajax({ type: 'POST', url: url, data: data, dataType: dataType, success: function () ...
- gitlab安装随记
gitlab安装 配置yum源 sudo vim /etc/yum.repos.d/gitlab-ce.repo 按照网上别人的例子,修改为清华的源 [gitlab-ce] name=Gitlab C ...
- ng-packagr 不能全部打包文件
1.没有在public_api.ts中导出 export * from './src/app/ngprime/components/tooltip/tooltip.module'; export * ...
- js设置radio单选框值选中
html页面: <div> <label><input type="radio" name="sex" value="m ...
- MySQL—ORM框架,sqlalchemy模块
武老师博客:ORM框架介绍 import os #1.当一类函数公用同样参数时候,可以转变成类运行 - 分类 #2.面向对象: 数据和逻辑组合在一起了 #3. 一类事物共同用有的属性和行为(方法) # ...