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

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

题目分析:

考查基本的数字变为字符串的操作;

实现方法:

计算结果由数字转为字符串存储,按位读取及显示;


#include "stdafx.h"

#include <stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d", &a, &b);

	c = a + b;

	if (c < 0)
	{
		printf("-");
		c *= (-1);
	}

	int count = 0;
	int tmp = c;
	char t[10];
	//for (i = 0;i)
	while(tmp!=0)
	{
		//count++;
		t[count++] = tmp %10 + '0';
		tmp = tmp / 10;
	}

	int sep = count /3;
	int LastNum = count % 3;

	int num = 0;

	if (LastNum == 0)
	{
		sep--;
	}

	if (sep < 0)
	{
		printf("0");
		return 0;
	}

	num = count - sep * 3;

	for (int i = 0;i<num;i++)
	{
		printf("%d", t[count - i - 1] - '0');
	}

	for ( int i = 0;i<sep;i++)
	{
		printf(",");
		for (int j = 0;j<3;j++)
		{
			printf("%d", t[count - num - 1] - '0');
			num++;
		}
	
	}



	return 0;
}


手把手式介绍 ADNI 影像数据下载 1.搜索 1.1登录 打开ADNI的官网:http://adni.loni.usc.edu/,进入下面的界面。 点击 DATA&SMPLES 下的 ACCESS DATA AND SAMPLES,如下图。 页面跳转以后点击中间的“LOGIN”,这时会跳出一个新的界面,然后在右上角输入自己的帐号、密码即可。如果没有权限可以跳转到第2部分看看如何申请权限。 登录以后选择DOWNLOAD下的 Image Collections就是搜索下载影像数据,其他还有一些学习测试数据和遗传数据。 1.2 sea 阅读详情

相关推荐

5分钟搞懂语义通信:如何用深度学习让AI理解你的真实意图?

本文深入解析了语义通信如何利用深度学习技术,实现从传统‘比特保真’到‘语义保真’的范式转移。通过介绍基于神经网络的端到端系统架构、编解码技术及实战案例,阐明AI如何理解并高效传递信息核心意图,为6G时代的人机交互奠定基础。

weixin_29191669的博客 263

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

Lama:基于傅立叶卷积的分辨率鲁棒性大掩模修复

为了缓解修复网络和损失函数都缺乏有效的感受野这个问题,提出了大掩模修复(LaMa)。LaMa基于一种新的修复网络架构,该架构使用快速傅立叶卷积(FFC),具有图像范围的感受野;高感受野感知损失;大型训练掩码,释放前两个组件的潜力。

qq_44926214的博客 1417

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

【机器人】线性方程最小二乘解法对机械臂DH参数进行标定

1.前言 看了一篇文章,觉得里面的DH参数标定法讲的很清晰,便使用Matlab复现了一下,效果还可以,特写此文记录。 2.原理 2.1.误差最佳值的最小二乘计算 有研究结果表明:几乎95%的机器人位置误差都是由机器人内部运动学的不准确描述引起的,所以对DH模型参数进行标定是很有必要的。 DH参数物理含义:选自《机器人学、机器视觉与控制-Matlab基础》 当DH参数确定后,我们...

要恰饭得嘛 1万+

【74HC595芯片】核心驱动代码

74HC595是一个8位串行输入、并行输出的位移缓存器:并行输出为三态输出。在SCK 的上升沿,串行数据由SDL输入到内部的8位位移缓存器,并由Q7’输出,而并行输出则是在LCK的上升沿将在8位位移缓存器的数据存入到8位并行输出缓存器。当串行数据输入端OE的控制信号为低使能时,并行输出端的输出值等于并行输出缓存器所存储的值。

weixin_67147824的博客 1847

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

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

努力努力再努力 280

带有HSE组件的S32系列芯片中各子系统如何依次启动?

仔细阐述了上电后各个子系统的启动顺序,并给出了详细的启动步骤流程图。

车载系统攻城狮 1702

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

PCL 欧式聚类(C++详细过程版)

为充分了解算法实现的每一个细节和有待改进的地方,使用C++代码对算法实现过程进行复现。

点云侠的博客 2448

Diffusion models代码实战:从零搭建自己的扩散模型

这个系列曾经写过三篇文章专门讲代码,分别从数据集、超参数、loss设计、参数计算、Unet结构、正向过程、逆向过程等部分详细介绍了如何搭建DDPM。Diffusion models领域发展神速,最近半年代表作品有OpenAI的GLIDE、DALL-E 2,Google Brain的ImageGen,海森堡大学的Latent Diffusion。这篇博客针对入门新手讲解一下如何利用已有的资源快速搭建自己的Diffusion models。.........

沉迷单车的追风少年 1万+

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

1001 A+B Format (20 分) 题目链接PAT A 1001 思路分析:这道题用字符串去解决可能比较方便,用到了C++11特性里的to_string函数,可以直接将数字转换为字符串。坑点就是它是从个位开始每三位加一个逗号,我一开始还傻乎乎的以为是从最高位。。。 AC代码: #include<iostream> using namespace std; int main(...

weixin_43684054的博客 213

YOLOv12涨点优化:自研检测头 | 独家创新(Partial_C_v12Detect)检测头结构创新,实现涨点

现有12Detect进行二次创新,提升检测精度,独家创新(Partial_C_12Detect)检测头结构创新,适合科研创新度十足,强烈推荐

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 632

[PAT-Advanced] A1001 A+B Format (20)

PAT甲级A1001题目+分析+题解

Duke 424

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

VB摄像头监控

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

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

ganlanA的博客 209

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

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

qq_40773319的博客 244

pscad IEEE标准系统搭建说明

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

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

[PAT] 1001 A+B Format (20 分)Java

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

Simma1101的博客 209

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

[C++]PAT 1001 A+B Format (20分)

Calculate a+ba + ba+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 ...

快乐de约定的博客 2093

[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

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

PAT:A1001 A+B Format (20 分)

PAT:A1001 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...

Ecloss 446

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 A1001 A+B Format (20)

题目链接: PAT A1001 A+B Format 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 S...

kkkk9501的博客 273
上一篇: PAT 1010. Radix (25)
下一篇: PAT 1002. A+B for Polynomials (25)
xuxumoi
博客等级 码龄16年 16粉丝 151原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值