【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 ( ...
随机推荐
- const与#define的区别、优点
const与#define的区别 编译器处理方式不同 define宏是在预处理阶段展开. 补充:预处理器根据以#开头的命令,修改原始的程序.比如我们常见的#include <stdio.h> ...
- C#堆和栈的入门理解
声明:以下内容从网络整理,非原创,适当待入个人理解. 解释1.栈是编译期间就分配好的内存空间,因此你的代码中必须就栈的大小有明确的定义:堆是程序运行期间动态分配的内存空间,你可以根据程序的运行情况确定 ...
- webpack-高级-发布策略
webpack的发布策略 在实际开发中,一般会有两套项目方案: 一套是开发期间的项目,包含了测试文件.测试数据.开发工具.测试工具等相关配置,有利于项目的开发和测试,但是这些文件仅用于开发,发布项目时 ...
- C# virtual 函数
C# virtual 是虚拟的含义,在 C# 语言中,默认情况下类中的成员都是非虚拟的,通常将类中的成员定义成虚拟的,表示这些成员将会在继承后重写其中的内容. virtual 关键字能修饰方法.属性. ...
- opencv:全局阈值
图像的二值化分割,最重要的就是计算阈值 阈值的计算方法很多,基本分为两类,全局阈值与自适应阈值 OTSU.Triangle #include <opencv2/opencv.hpp> #i ...
- sqli-libs(32-37(宽字节注入)关)
补充知识:宽字节注入 定义:GB2312.GBK.GB18030.BIG5.Shift_JIS等这些都是常说的宽字节,实际上只有两字节.宽字节带来的安全问题主要是吃ASCII字符(一字节)的现象,即将 ...
- XSS常见攻击与防御
XSS攻击全称跨站脚本攻击,是为不和层叠样式表(Cascading Style Sheets, CSS)的缩写混淆,故将跨站脚本攻击缩写为XSS,XSS是一种在web应用中的计算机安全漏洞,它允许恶意 ...
- eclipse提示错误:save could not be completed
原博客地址:https://blog.csdn.net/alane1986/article/details/6514000 2010年12月06日 19:20:00 alane1986 阅读数:150 ...
- 【算法】dsu on tree初探
dsu on tree的本质是树上的启发式合并,它利用启发式合并的思想,可以将O(N^2)的暴力优化成O(NlogN),用于不带修改的子树信息查询. 具体如何实现呢?对于一个节点,继承它重儿子的信息, ...
- docker中安装mysql遇到的问题
在虚拟机上用docker安装了一个mysql最新版,然后在本地用sqlyog区连接报错‘plugin cachin_sha2_password could not be loaded’经过上 ...