【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 ( ...
随机推荐
- python 变量的赋值【内存地址】
注意: python所有的数据都是对象,变量只是指向一个对象的地址,一旦将变量的值或者类型改变,变量指向的地址就有可能发生变化 这个特性在使用默认参数的时候一定要注意
- 普及C组第二题(8.2)
1340. [南海2009初中]jumpcow(牛跳) (Standard IO) 题目: John的奶牛们计划要跳到月亮上去.它们请魔法师配制了 P (1 <= P <=150,000) ...
- opencv:形态学梯度
#include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace st ...
- bugku 头等舱
先查看题目发现页面是这一个 然后打开后台F12 发现后台什么也没有 然后使用抓包burpsuit 然后发现答案就在其中 (首先右键转到repeater然后点击go)
- ajax和promise及axios和promise的结合
链接:https://www.cnblogs.com/mmykdbc/p/10345108.html 链接2:https://blog.csdn.net/UtopiaOfArtoria/article ...
- eureka-获取服务列表(各种状态)
在刚开始做的时候也搜了下搜到的大多是下面的第一种方法,这种方法很简单,但并不是Eureka展示的那个服务列表,他只包括了注册证成功的,或者说eureka中状态为“Up”的实例列表,对于down掉的实例 ...
- 外键约束:foreign key
*外键 foreign key* 1.概念:如果一个实体的(student)的某个字段,指向(引用)另个实体(class)的主键 (class:class_id),就称为student实体的class ...
- 每天进步一点点------SysTimer
/******************************************************************** * 文 件 名:SysTimer_test.c * 功 能: ...
- XMOS发布集单片机,AI,FPGA,DSP于一身的跨界处理器完全体xcore.ai,致力于AIOT,售价1美元起步
说明:XMOS这次致力于打造全新的,颠覆性的嵌入式平台,简化开发人员要学一堆东西才能开发一款高性能AIOT产品的痛点. XCORE.AI集单片机,AI,FPGA,DSP于一身,嵌入式软件开发人员可以灵 ...
- Yii2框架 常用函数整合
1.使用事务添加数据: public function create() { if($this->validate()) { $trans = Yii::$app->db->begi ...