PAT_甲级_1001. A+B Format (20)

SAP ABAP BAPI_PRODORD_CHANGE:动态刷新PP主数据的实战解析 本文深入解析了在SAP ABAP开发中,如何利用BAPI_PRODORD_CHANGE函数实现生产订单PP主数据的动态刷新。针对CO02事务码无法满足的后台自动化场景,详细讲解了通过设置explosion_date和explode_new等关键参数来强制重新读取BOM和工艺路线的实战方法,并提供了核心代码示例与避坑指南,确保生产订单信息与最新主数据同步。 阅读详情

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

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

 

题目链接http://www.patest.cn/contests/pat-a-practise/1001

 

c++实现

 

#include <iostream>
#include <iomanip>
#include <stack>//栈头文件
using namespace std;
int main()
{
	int a, b, sum;
	cin >> a >> b;
	sum = a + b;
	stack<int> stk;//构造一个栈
	if (sum == 0)
	{
		stk.push(0);
	}
	else if (sum < 0)
	{
		cout << "-";
		sum = -sum;
	}
	while (sum != 0)
	{
		stk.push(sum % 1000);//取最后三位(百位十位个位)的部分入栈
		sum = sum/1000;
	}
	cout << stk.top();
	stk.pop();
	while (!stk.empty ())
	{
		cout << ',' << setfill('0') << setw(3) << stk.top();//setfill('0')空余处填充0,setw(3)设置输出宽度3
		stk.pop();
	}
	//system("pause");
	return 0;
}

 

源代码链接

https://github.com/varvelworld/PAT-Advanced-Level-Practise/blob/master/1001/1001.cpp

==========

2015.7.18

我的java

 

import java.util.*;
import java.math.*;
import static java.lang.System.*;
public class Main 
{
	public static void main(String[] args) 
	{
		// TODO Auto-generated method stub
		Scanner cin=new Scanner(System.in);
		int greater_0=0,count=0;//greater_0控制添加','号,count控制添加','
		BigInteger a=cin.nextBigInteger();//大整型a
		BigInteger b=cin.nextBigInteger();//大整型a
		BigInteger sum=a.add(b);//计算a+b
		String result="";//保存添加','后的数字
		greater_0=sum.compareTo(BigInteger.valueOf(0));//判断sum>=0
		if(greater_0==-1)//若sum<0,则将sum转换为正整数
		{
			sum=sum.multiply(BigInteger.valueOf(-1));
			out.print("-");//输出sum前面的符号
		}
		String s=sum.toString();//将大整形sum转换为字符串
		for(int i=s.length()-1;i>=0;i--)
		{
			result=result+String.valueOf(s.charAt(i));//将sum的字符分别添加进字符串result
			count++;//控制添加','号
			if(count%3==0&&i!=0)//除sum第一个位置外,其它位置每满3个字符则添加','
				result=result+",";
		}
		for(int j=result.length()-1;j>=0;j--)//倒序输出result
		{
			out.print(result.charAt(j));
		}
	}
}

 

 

 

 

 

【stm32+K210项目】基于K210与STM32协同工作的智能垃圾分类系统设计与实现(完整工程资料源码) 本系统采用SG90舵机Maix Bit摄像头STM32C8T6主控板以及LX_TRIG_MP3_V6.0语音播报模块,构建了一套高效的智能垃圾分类系统,综合运用了图像识别、语音播报及精准控制技术。SG90舵机负责控制垃圾桶的开盖操作。该舵机通过接收PWM信号来实现转动,内部有一个基准电路产生周期为20ms的PWM信号,通过外部脉冲信号的控制(高电平时间在0.5ms至2.5ms之间),使得舵机的输出轴转动到指定位置。舵机内的位置反馈电位计。 阅读详情

相关推荐

【MATLAB+VScode】VScode调试MATLAB代码的终极指南

本文详细介绍了在VScode中调试MATLAB代码的完整方案。通过配置MATLAB Engine for Python作为桥梁,实现在VScode中设置断点、单步执行、查看变量等交互式调试功能,有效结合了VScode的现代化编辑体验与MATLAB的强大计算内核,显著提升开发效率。

weixin_29161719的博客 412

PAT甲级(Advanced Level)----1001

1001 A+B Format (20point(s)) 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. E

zeroming的博客 242

Mac上安装虚拟机搭载window系统

用Mac的都知道,很多window用的软件是Mac版本没有的。平时有的还得要求去用那些软件,有几种方式可供大家选择: 1.再买个window本; 2.装双系统; 3.装虚拟机,搭载window系统。 我比较推荐第3条,这样可以在Mac本上做到双开,一边开着mac一边开着window,还能做到同时处理文件,不至于重新启动操作系统,下边是具体实现步骤,其中有几个需要下载的,建议在网速好的时候完...

Coder_Mumu的博客 1万+

PAT甲级1001java解题

PAT甲级java解题 题目: 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...

yijiezun8614的博客 230

ROS 2 Slam Toolbox实战:从零跑通2D激光建图

SLAM(同步定位与地图构建)是移动机器人实现自主导航的基础技术,其核心在于通过传感器数据实时估计位姿并构建环境栅格地图。slam_toolbox作为ROS 2 Humble及后续LTS版本官方主推的2D SLAM后端,采用图优化+闭环检测架构,兼顾实时性、鲁棒性与工程可维护性。相比cartographer和hector_slam,它原生支持ROS 2、参数精简、诊断友好,特别适合硬件资源有限、缺乏IMU或深度相机的差速机器人平台。本文聚焦真实部署场景,覆盖RPLIDAR等常见2D激光雷达与TurtleBo

weixin_30596165的博客 357

RAG 赋能客服机器人:多轮对话与精准回复

在人工智能技术飞速发展的今天,客服机器人已成为企业提升服务效率的重要工具。然而,传统客服系统在多轮对话连贯性和精准回复能力上存在明显短板。检索增强生成(Retrieval-Augmented Generation, RAG)技术通过结合大语言模型(LLM)与外部知识库,为解决这一问题提供了创新路径。本文将深入探讨 RAG 在客服机器人中的应用,重点分析其如何实现多轮对话与精准回复,并结合实际案例与技术框架展开讨论。

shuizhudan223的博客 2142

PAT甲级1001

首先用“%”和“/”把计算结果保存到数组里,然后从高位开始输出,在输出的同时数数,还剩3位或者6位时加“,”。

qq_45846199的博客 579

第七天 Labview进阶(7.3 Teststand简单使用)

TestStand是NI开发的自动化测试管理软件,支持多语言编程和硬件集成,广泛应用于电子产品和工业测试。安装时需注意版本选择,2022版支持离线安装。使用步骤包括:1)创建测试序列文件;2)插入测试动作并配置参数(如选择VI路径、设置变量);3)添加条件判断和延时控制;4)执行测试序列时具备流程控制功能,如失败步骤自动跳过后续测试。该软件能有效提升测试效率与准确性,通过可视化操作实现复杂测试流程管理。

weixin_38637405的博客 1730

[PAT甲级]1001. 经典a+b问题

菜狗的PAT第一天从朴实无华的a+b开始捏

hzykirito的博客 261

Claude Code Cli 源码泄露事件全解析:从51万行代码中拆解AI Agent的记忆护城河

2026年3月,Anthropic的AI编程助手Claude Code意外泄露51万行核心代码,暴露了其多Agent架构、六级权限验证系统及创新的记忆机制。记忆系统采用四层设计:用户自定义框架、自动记忆提取、智能上下文压缩和纯文件存储。最独特的是"自动做梦"功能,AI会定期整理记忆,类似人类睡眠记忆巩固。代码还揭示未发布功能如电子宠物系统,但也暴露权限系统漏洞和代码质量问题。这次泄露展现了AI助手核心技术的复杂性,特别是其记忆系统如何通过透明可编辑的设计建立用户信任。

program哲学 469

【Python爬虫(1)】专栏开篇:夯实Python基础

要想熟练掌握 Python 爬虫技术,扎实的 Python 基础是必不可少的。这就好比建造高楼大厦,Python 基础就是那稳固的基石。只有打好了这个基础,我们才能在爬虫的学习道路上稳步前行,理解并运用各种爬虫技术和框架。

邓邓子的博客 2026

PAT甲级真题(1001)

PAT真题(1001)题目解析源码测试结果 题目 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 Spe...

小王同学的博客 705

深度强化学习 | 详解基于价值的强化学习DQN算法(附Pytorch实现)

深度Q网络DQN的核心原理是通过经验回放池和目标网络技术拟合高维状态空间,是Q-Learning算法的深度学习版本,本文分析DQN的基本算法,并给出训练实例和实际案例

FRIGIDWINTER的博客 4986

PAT 1001 A+B Format (20 分) ——甲级

#include<iostream> #include<string> using namespace std; int main(){ int a, b, c; scanf("%d %d", &a, &b); c = a + b; if(c < 0){ c = -1 * c; printf("-"); } string str1...

RickLin_的博客 155

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

PAT 甲级 1001 A+B Format (20 分)

题目:PAT 甲级 1001 A+B Format (20 分) 经验总结: 两数之和的结果有三种可能:正数、0、负数。特别要注意0的情况,不要忽视了。 解法一(数字转字符串处理):首先将数字结果转换成字符串,判断是否是负数,是负数就先把负号输出,然后去掉负号再对剩下的数字做判断。如果要输出逗号,那么这个逗号的前面必须且至少有个数字。所以可以遍历字符串,输出当前字符后,判断从当前字符开始到...

努力努力再努力 280

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

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 groups of three by commas (unless there are less than four digits). Inpu...

weixin_43795683的博客 388

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

PAT甲级 A1001. A+B Format (20)

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 cas

weixin_43977129的博客 320

PAT甲级 1001 A+B Format (20 分)

PAT甲级 1001 A+B Format 20 分PAT甲级 1001 A+B Format (20 分)Input Specification:Output Specification:Sample Input:Sample Output:解释代码 PAT甲级 1001 A+B Format (20 分) Calculate a+b and output the sum in standard...

weixin_41699413的博客 333

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 groups of three by commas (unless there are less than four digits). Input Specification: Each input file contains one test case. E

linjiayina的博客 191

PAT甲级1001 A+B Format (20 分) c++

PAT甲级1001 A+B Format (20 分) c++ 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). Inp...

DyP__优快云的博客 404

【JAVA】1001 A+B Format (20分) PAT甲级 PAT (Advanced Level) Practice

目录1001 A+B Format (20分)思路一:不按他们的位数分情况处理代码一:用可变数组ArrayList+字符串截取方法subString代码二:栈Stack+字符串截取方法subString思路二:因为a和b的范围较小,所以可以按他们的位数分情况处理代码一:字符串截取方法substring代码二:StringBuilder的insert方法代码三:格式化输出 printf 1001 A...

子浩的博客 1万+

PAT甲级 1001 A+B Format (20分)

PAT甲级 10011 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 c

YesterdayLee的博客 207

[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 must be separated into groups of three by commas (unless there are less than four digits). Input Specif...

cp0328的博客 3390

PAT 甲级 1001 1001 A+B Format (20 分) 我的解法+别人的解法

原PAT网站用户可在 https://patest.cn/bind_old_pat_user 页面绑定至拼题A账号。绑定后,原PAT网站的提交将被合并至拼题A网站用户的对应题目集中。 返回 1001 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits m...

小渣渣的博客 853

PAT甲级 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). 输入信息 Each input file contains ...

qq_26073557的博客 334

【PAT甲级】【1001】 A+B Format (20分)

问题描述: Calculatea+band 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: Ea...

Aspril.L 308
上一篇: c++实现对称矩阵的压缩存储
下一篇: 浙江大学PAT_甲级_1006. Sign In and Sign Out (25)
pythontojava
博客等级 码龄12年 84粉丝 140原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值