1082 Read Number in Chinese (25 分)

Android 12.0 以太网和wifi共存的产品wifi优先级设置功能实现 在12.0的系统ROM定制化开发中,在对于一些有线网和wifi共存的产品中,由于某些产品的特殊要求首选使用wifi,而在原生 系统中以太网的优先级高于wifi的,所以就需要从优先级的设置来分析,实现设置优先级的相关功能实现 阅读详情

在这里插入图片描述
1082 Read Number in Chinese (25 分)
Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 is read as Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu. Note: zero (ling) must be handled correctly according to the Chinese tradition. For example, 100800 is yi Shi Wan ling ba Bai.

Input Specification:
Each input file contains one test case, which gives an integer with no more than 9 digits.

Output Specification:
For each test case, print in a line the Chinese way of reading the number. The characters are separated by a space and there must be no extra space at the end of the line.

Sample Input 1:
-123456789
Sample Output 1:
Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu
Sample Input 2:
100800
Sample Output 2:
yi Shi Wan ling ba Bai

#include<iostream>
using namespace std;
string digits[10] = { "ling","yi","er","san","si","wu","liu","qi","ba","jiu" };
string units[5] = { "Yi","Wan","Qian","Bai","Shi" };
int main() {
	string s;
	cin >> s;
	if (s[0] == '-') {
		cout << "Fu ";
		s = s.substr(1, s.length() - 1);
	}
	if (s.length() == 9) {
		cout << digits[s[0] - '0'] << " " << units[0] << " ";
		s = s.substr(1, s.length() - 1);
	}
	if (s.length() <= 8&&s.length()>=5) {
		string t= s.substr(0, s.length() - 4);
		s = s.substr(s.length() - 4, 4);
		if (t == "0000") goto next;
		bool flag = false;
		for (int i = 0; i < t.length() ; i++) {
			if (t[i] == '0'&&flag==false) cout << digits[0] << " ";
			else {
				if (t[i] == '0' && flag == true) break;
 				if(t[i]!='0') cout << digits[t[i] - '0'] << " ";
				if (t.length() == 4) {
					if (i == 0 && t[1] == '0' && t[2] == '0' && t[3] == '0') {
						cout << units[2] << " ";
						flag = true;
					}
					else if(i==0)cout << units[2] << " ";
					if (i == 1 && t[2] == '0' && t[3] == '0') { 
						cout << units[3] << " "; flag = true;
					}
					else if(i==1)cout << units[3] << " ";
					if (i == 2 && t[3] == '0') { 
						cout << units[4] << " ";
						flag = true;
					}
					else if(i == 2) cout << units[4] << " ";
				}
				else if (t.length() == 3) {
					if (i == 0 && t[1] == '0' && t[2] == '0') {
						cout << units[3] << " ";
						flag = true;
					}
					else if (i == 0)cout << units[3] << " ";
					if (i == 1 && t[2] == '0') {
						cout << units[4] << " ";
						flag = true;
					}
					else if (i == 1)cout << units[4] << " ";
				}
				else if (t.length() == 2) {
					if (i == 0 && t[1] == '0') {
						cout << units[4] << " ";
						flag = true;
					}
					else if (i == 0)cout << units[4] << " ";
				}
			}
		}
		cout << units[1]<<" ";
	}
	next:
	if (s.length() <= 4 && s.length() >= 1) {
		string t = s;
		bool flag = false;
		if (t == "0") { cout << digits[0]; goto last; }
		if (t == "0000") goto last;
		if (t[0] == '0' && t[1] == '0' && t[2] == '0') {
			cout << digits[0] << " " << digits[t[3] - '0']; goto last;
		}
		for (int i = 0; i < t.length() ; i++) {
			if (t[i] == '0' && flag == false) cout << digits[0] << " ";
			else {
				if (t[i] == '0' && flag == true) break; 
				if (t[i] != '0' && i != t.length() - 1) cout << digits[t[i] - '0'] << " ";
				else cout << digits[t[i] - '0'];
				if (t.length() == 4) {
					if (i == 0 && t[1] == '0' && t[2] == '0' && t[3] == '0') {
						cout << units[2];
						flag = true;
					}
					else if (i == 0)cout << units[2] << " ";
					if (i == 1 && t[2] == '0' && t[3] == '0') {
						cout << units[3]; flag = true;
					}
					else if (i == 1)cout << units[3] << " ";
					if (i == 2 && t[3] == '0') {
						cout << units[4];
						flag = true;
					}
					else if (i == 2) cout << units[4] << " ";
				}
				else if (t.length() == 3) {
					if (i == 0 && t[1] == '0' && t[2] == '0') {
						cout << units[3];
						flag = true;
					}
					else if (i == 0)cout << units[3] << " ";
					if (i == 1 && t[2] == '0') {
						cout << units[4];
						flag = true;
					}
					else if (i == 1)cout << units[4] << " ";
				}
				else if (t.length() == 2) {
					if (i == 0 && t[1] == '0') {
						cout << units[4];
						flag = true;
					}
					else if (i == 0)cout << units[4] << " ";
				}
			}
		}
	}
	last:
	return 0;
}
你的小程序地图功能还只是“摆设”吗?支付宝地图API的深度玩法都在这里了! 🏆本文收录于《滚雪球学支付宝小程序开发》专栏,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!! 阅读详情

相关推荐

手把手教你用QEMU虚拟化华为路由器固件(附完整网络配置指南)

本文提供了一份详尽的QEMU虚拟化华为路由器固件的实战指南。从固件解包、网络桥接配置到QEMU虚拟机启动,手把手教你搭建完整的嵌入式设备沙箱环境,特别适合安全研究、逆向分析和学习嵌入式系统工作原理。

tgb3456789的博客 937

PAT 甲级 1082  Read Number in Chinese

1082 Read Number in Chinese (25 point(s)) Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123...

漫浸天空的雨色的备忘录~ 804

奇异值分解(SVD)C++实现

奇异值分解SVD(紧奇异值分解,截断奇异值分解)C++实现

weixin_45804601的博客 4172

甲级PAT 1082 Read Number in Chinese (字符串处理,中国式读数)

1082 Read Number in Chinese (25 分) Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 ...

Joyceyang_999的博客 526

ESP32+HC-SR04超声波测距:5分钟搞定智能避障小车核心功能(附完整代码)

本文详细介绍了如何使用ESP32开发板和HC-SR04超声波测距模块快速构建智能避障小车的核心功能。通过优化的接线方案、核心代码实现及调试技巧,帮助开发者5分钟内完成硬件连接与软件编程,实现高效的避障功能。附完整代码,适合创客教育和机器人开发。

weixin_29185199的博客 384

【迁移学习综述】

迁移学习的目标是将某个领域或任务上学习到的知识应用到不同的但相关的领域或问题中。迁移学习的研究来源于一个观测:人类可以将以前的学到的知识应用于解决新的问题,更快的解决问题或取得更好的效果。迁移学习被赋予这样一个任务:从以前的任务当中去学习知识(knowledge)或经验,并应用于新的任务当中。换句话说,迁移学习目的是从一个或多个源任务(source tasks)中抽取知识、经验,然后应用于一个目标领域(target domain)当中去。

afadgas的博客 4319

PAT A1082 Read Number in Chinese

A1082: Read Number in Chinese (25 分) Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 is read as Fu yi Yi er Qian san Bai si Shi wu Wan liu Q

CRX的博客 309

004.PADS VX2.4常用快捷键及无模命令

PADS系列文章

qq_36492361的博客 4967

PAT甲级真题 1082 Read Number in Chinese (25分) C++实现(中文读数,分治法)

题目 Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output “Fu” first if it is negative. For example, -123456789 is read as “Fu yi Yi er Qian sa...

zhang35的博客 423

开源Harness项目DeerFlow 2.0,让智能体几乎能完成任何复杂任务

从提示工程到上下文工程,再到如今的 Harness,这条演进路径的本质是从“教模型如何理解人类”迈向“为模型构建一个可执行、可信赖、可长期运转的数字世界”。 当越来越多像 DeerFlow 2.0 这样的 Super Agent Harness 走向普及,AI 将真正进化为能理解、会规划、可执行、敢交付、长期负责的成熟生产力形态。

技术引领业务创新 519

导数与微分在 FPS 射击游戏中的实际应用:把“手感”算出来

摘要:射击游戏开发中,单线程适用于简单小游戏(如单机打靶),所有任务由主线程顺序处理,代码简单但效率较低;多线程则适合复杂场景(如多人在线3D大作),通过渲染、逻辑、网络、音效等线程分工协作,确保画面流畅、响应迅速和实时同步。选择依据取决于游戏复杂度、联网需求和性能要求,小型游戏用单线程,大型高要求项目必须采用多线程架构。(149字)

本博客聚焦游戏开发技巧、创业实战心得及大学热门课程干货。这里既有技术深度,也有思维广度,无论你是开发者、创业者还是高校学子,都能在这里找到适合自己的成长之路! 3278

1082 Read Number in Chinese (25分)--PAT甲级真题

Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 is read as Fu yi Yi er Qian san Bai ...

Samson的博客 191

芯片研发完整全流程

芯片研发全流程可分为需求与架构设计、前端逻辑设计、后端物理设计、晶圆制造、封装测试五大阶段,涉及16个核心步骤。研发过程需要多学科交叉协作,包括微电子、物理、材料、计算机等。关键注意事项包括验证优先、工艺约束遵循、可测性设计等。芯片设计需要绘制纳米级精度的物理版图,而非传统工程图纸,需使用专业EDA工具而非KiCad这类PCB设计软件。完整研发流程具有高投入、高风险特点,需严格遵循行业标准和规范。

weixin_44520581的博客 230

1082 Read Number in Chinese (25 分)

1082 Read Number in Chinese (25 分) Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 ...

qq_39339575的博客 418

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

NTscan扫描工具

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

1082 Read Number in Chinese (25 分)

1082Read Number in Chinese(25分) Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. OutputFufirst if it is negative. For example, -123456789 ...

树叶子的博客 299

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

1082 Read Number in Chinese (25 分)

A1082 #include &lt;cstdio&gt; #include&lt;cstring&gt; int main() { char num[][10]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"

学习为主,偶尔扯淡 404

pscad IEEE标准系统搭建说明

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

1082 Read Number in Chinese (25 分)

  Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 is read as Fu yi Yi er Qian san B...

韩江雪de 小屋 540

【1082】Read Number in Chinese (25 分)

#include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<string> #include<algorithm> #include<map> #inclu...

发现问题,并解决问题,批判性思维 656

【PAT 甲级】1082 Read Number in Chinese (25 分)

1082 Read Number in Chinese (25 分) Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. OutputFufirst if it is negative. For example, -123456789 ...

CrystalXueNing的博客 890

1082 Read Number in Chinese (25分)

题目 Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 is read as Fu yi Yi er Qian san B...

小白的博客 154

A1082 Read Number in Chinese (25 分)

1082 Read Number in Chinese (25 分) Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For ex...

weixin_30722589的博客 173
上一篇: 1077 Kuchiguse (20 分)
下一篇: 1025 PAT Ranking (25 分)
好想当依蕾娜小姐的狗
博客等级 码龄7年 0粉丝 62原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值