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

NE555高频雾化驱动电路设计与谐振匹配原理 超声波雾化器驱动本质是机电能量转换系统,其核心在于电气驱动频率与压电陶瓷机械谐振频率的精准匹配。基于NE555的多谐振荡器通过RC网络生成基准时钟,其频率公式f1.44/[(R₁+2R₂)C₁]揭示了电容作为主控变量的关键作用;而从低频1Hz到高频200kHz的电容量级跨越(10⁶倍),直接引发寄生参数主导、测量工具失效及电路建模升级三大工程跃变。结合MOSFET开关特性、LC谐振升压与高频去耦设计,该方案实现了高压高频激励下的高效率雾化。本文聚焦NE555在雾化驱动中的时钟源角色与谐振匹配实践,覆盖参数计 阅读详情

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));
		}
	}
}

 

 

 

 

 

国产FPGA高云GW1NSR-4C,集成ARM Cortex-M3硬核 从板子整体角度来看,这是一款国产化程度很高的板子,从主控FPGA,到JTAG芯片,存储芯片、电源芯片等,都是使用的国产半导体公司的产品。板子整体尺寸也比较迷你,属于小而美类型的,可以认为是一款FPGA核心板,当然也预留了排针接口,给用户足够的扩展空间。对于想了解高云小蜜蜂SoC软硬件开发,以及对云源软件、MCU开发环境做个深度评测来说足够了。JTAG调试器固件可以增加虚拟串口功能,对于板子本来来说面积不会有改动,只需要添加两根信号线即可。 阅读详情

相关推荐

【ROS学习笔记】8.话题消息(Message)的定义与使用

ROS学习笔记8——话题消息(Message)的定义与使用

takedachia的博客 9558

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的博客 243

CST--时域仿真的网格设置技巧

对于物理概念清晰的工程师而言,使用时域算法几乎能够解决所有电磁仿真问题,但是,掌握时域算法的仿真技巧比掌握频域的难度大,这恐怕也是很多仿真工程师更喜欢使用频域算法的原因,因此,对于时域算法的灵活应用更能考验你是否是一名合格的仿真工程师。

一只豌豆象的博客 6901

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

基于C#的跨平台上位机开发:一次编写,多平台运行

摘要: 本文探讨了如何利用C#进行跨平台上位机开发,以适配Windows、Linux、macOS等多平台需求。通过分析传统单平台开发的局限性(如API差异、硬件接口兼容性),提出基于.NET 5/6/7的解决方案,重点推荐Avalonia(类WPF的跨平台UI框架)和GtkSharp(基于GTK+)实现图形界面。同时,针对硬件通信需求,介绍了System.IO.Ports串口通信和LibUsbDotNet的跨平台支持,并强调多平台调试(VS Code、Docker)的重要性,最终实现一次编码、多端部署的高效

这里只有干货:从 Modbus 到 MES,从 YOLO 到工控机部署;65 篇现场排障案例,每篇都写到改哪一行。 1430

【计算机组成原理实验】状态机实验

理解“状态机”概念,掌握“状态机”思想描述时序系统。通过下列三种基于D触发器的计数器结构,构建状态机的状态转移电路:环形计数器、扭环计数器和条件判断的扭环计数器。基于“状态机”原理,设计一个“交通灯”系统:控制红黄绿信号灯按照以下顺序循环点亮:“绿 黄 红 绿 ……”,红灯、绿灯和黄灯的亮灯持续时间可以通过拨码开关独立设置。红灯和绿灯是持续亮灯模式,黄灯则是闪烁亮灯模式。

Rover_jb的博客 1340

PAT甲级1001

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

qq_45846199的博客 580

VS Code配置MinGW64编译非线性优化库NLopt

VS Code用MinGW64编译C++代码安装MSYS2软件并配置非线性优化库NLopt和测试引用库代码的完整具体步骤。:若使用非UCRT版本(如传统MinGW64),替换所有路径中的。库文件会自动安装到MSYS2的。

weixin_30777913的博客 906

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

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

hzykirito的博客 262

手把手教你学Simulink--双足机器人分数阶PID控制仿真

分数阶PID(Fractional-order PID, FOPID)控制是一种先进的控制策略,它扩展了传统的整数阶PID控制器的概念。FOPID控制器允许积分和微分项的阶次不是严格的整数,而是可以是任意实数,这为系统提供了更多的设计自由度,并可能带来更好的性能。在双足机器人控制中,分数阶PID控制可以用于改善机器人的平衡控制、轨迹跟踪等任务的性能。下面我们将详细介绍如何使用Simulink进行基于分数阶PID控制方法的双足机器人仿真研究。

MHD0815的博客 922

KRC文件——编程中的重要文件

KRC文件是指KUKA机器人控制器(KUKA Robot Controller)所使用的文件格式。KUKA是一家知名的机器人制造商,其机器人控制器通过KRC文件来管理和执行机器人程序。KRC文件包含了机器人的运动指令、逻辑控制、传感器数据等信息,以及与机器人相关的配置参数。这些文件通常使用KRL(KUKA Robot Language)编写,是一种特定的编程语言。KRC文件具有扩展名为.krc的格式,可以在KUKA机器人控制器上直接加载和执行。

TechProX的博客 2977

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...

小王同学的博客 708

Uncaught ReferenceError: process is not defined

这个错误 Uncaught ReferenceError: process is not defined 通常出现在浏览器环境中,因为 process 是 Node.js 环境的内置对象,并不是浏览器原生支持的。因此,浏览器无法识别 process,导致该错误。在App.vue中加上以下代码就能够有效解决。

猿小白的博客 1754

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

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

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

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

努力努力再努力 284

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

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

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

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的博客 322

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的博客 192

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__CSDN的博客 407

【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的博客 210

[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的博客 3391

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的博客 336

【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 309
上一篇: 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、付费专栏及课程。

余额充值
⌂ 换网址