【PAT - 甲级1005】Spell It Right (20分) (递归输出,水题)

题干:

Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.

Input Specification:

Each input file contains one test case. Each case occupies one line which contains an N (≤10​100​​).

Output Specification:

For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line.

Sample Input:

12345

Sample Output:

one five

解题报告:

考察就是递归输出而已。注意输出格式的控制。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define FF first
#define SS second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;
ll ans;
char s[MAX];
char db[10][102] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
void out(ll x) {if(x <= 9) printf("%s",db[x]);else {out(x/10); printf(" %s",db[x%10]);}
}
int main()
{cin>>s+1;int len = strlen(s+1);for(int i = 1; i<=len; i++) {ans += s[i] - '0';}out(ans);return 0;
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/439476.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

详解自动驾驶仿真数据集 SHIFT:A Synthetic Driving Dataset for Continuous Multi-Task Domain Adaptation

SHIFT&#xff1a;A Synthetic Driving Dataset for Continuous Multi-Task Domain Adaptation本文介绍一个新的自动驾驶仿真数据集&#xff1a;SHIFT&#xff0c;论文收录于 CVPR2022。适应连续变化的环境是自动驾驶系统一直以来要面临的挑战。然而&#xff0c;目前现有的图像…

TFS下的源代码控制

以下主要描述了&#xff1a; TFS源代码控制系统的基本场景如何把一个项目添加到源代码管理中如何与服务器同步如何做Check-In如何做分支与合并什么是上架与下架 我们知道工作项是项目管理的基本元素&#xff0c;但是一个项目的成功&#xff0c;光有工作项还是不够的。工作项说…

【PAT - 甲级1004】Counting Leaves (30分) (dfs,递归)

题干&#xff1a; A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each input file contains one test case. Each case starts with a line containing 0<N<100,…

地平线:面向规模化量产的智能驾驶系统和软件开发

导读 7月27日&#xff0c;地平线在智东西公开课开设的「地平线自动驾驶技术专场」第3讲顺利完结&#xff0c;地平线智能驾驶应用软件部负责人宋巍围绕 《面向规模化量产的智能驾驶系统和软件开发》这一主题进行了直播讲解。本次分享主要分为以下4个部分&#xff1a; 1、智能驾驶…

【转】TFS上分支和标签的用法

什么时候用分支: 例如为某个客户定制的专用版本,和主干的特性有很大差别.不具通用性的需求. 大的版本修改,例如2.0 到3.0 加了很多特性,但2.0 还有维护.改bug 什么时候用标签: 小版本的发布, 如2.1.1到2.1.2. 分支的优点: 清晰,容易操作,程序员只要get latest/checkin latest就…

【PAT - 甲级1034】Head of a Gang (30分)(并查集)

题干&#xff1a; One way that the police finds the head of a gang is to check peoples phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all the phone c…

重读经典(CLIP上):《Learning Transferable Visual Models From Natural Language Supervision》

CLIP 论文逐段精读【论文精读】这一次朱毅博士给大家精读的论文是 CLIP&#xff0c;来自于 OpenAI&#xff0c;是图像文本多模态领域一个里程碑式的工作。 CLIP 的影响力可见一斑&#xff0c;如果按照沐神之前讲的如何判断一个工作的价值来说&#xff0c;CLIP 应该就是 1001001…

TFS准备(一)

一、TFS概念&#xff1a; TFS全称Team FoundationServer&#xff0c;是应用程序生命周期管理的服务端&#xff0c;功能包括如图功能&#xff1a;源代码管理&#xff0c;版本控制&#xff0c;团队开发协作&#xff0c;统一集成&#xff0c;测试管理等。 二、TFS安装要求&#…

【PAT - 甲级1094】The Largest Generation (25分)(dfs建树)

题干&#xff1a; A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population. Input Specification: Each input file contai…

重读经典(CLIP下):《Learning Transferable Visual Models From Natural Language Supervision》

上文链接&#xff1a;重读经典&#xff08;CLIP上&#xff09;&#xff1a;《Learning Transferable Visual Models From Natural Language Supervision》 5. 实验 现在我们已经知道 CLIP 是如何进行预训练的以及作者为什么选用对比学习来预训练 CLIP&#xff0c;接下来我们就…

TFS创建团队项目(三)

打开Visual Studio 2013&#xff0c;视图-团队资源管理器-连接图标&#xff08;插头图标&#xff09; 当前是没有TFS服务器&#xff0c;点击服务器按钮 添加&#xff0c;并在URL地址栏里输入装有TFS的服务器IP地址&#xff08;配置完TFS后有这个URL&#xff1a;http://tfs-serv…

【PAT - 甲级1007】Maximum Subsequence Sum (25分)(前缀和)

题干&#xff1a; Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i1​​, ..., N​j​​ } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the l…

详解4D毫米波雷达数据集(VOD)Multi-class Road User Detection with 3+1D Radar in the View-of-Delft Dataset

Multi-class Road User Detection with 31D Radar in the View-of-Delft Dataset本文介绍一个新的自动驾驶数据集&#xff1a;VOD&#xff0c;论文收录于 ICRA2022。下一代毫米波雷达除了提供距离、方位和多普勒速度外&#xff0c;还会提供高度信息。 在本文中&#xff0c;作者…

自动驾驶之心:毫米波雷达-视觉融合感知方法(前融合/特征级融合/数据级融合)

毫米波雷达-视觉融合感知方法&#xff08;前融合/特征级融合/数据级融合&#xff09;分享一个自动驾驶之心的报告&#xff1a;毫米波雷达与视觉融合目标检测。 作者主页为&#xff1a;https://www.zhihu.com/people/nacayu 文章目录1. 毫米波雷达与相机融合检测背景2. 主流融合…

【PAT - 甲级1095】Cars on Campus (30分)(模拟)

题干&#xff1a; Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you are supposed to tell, at any specific t…

TFS中的迭代(五)

从团队资源管理器中打开迭代选项。 TFS在新建完团队项目后会自动为本团队项目新建迭代子项&#xff0c;包含发布和冲刺。第一级为团队项目TestProject&#xff0c;第二层为发布&#xff0c;第三层为冲刺&#xff0c;这样的层次一共可以建14层。 这些选项可以编辑&#xff0c;添…

2022百度ApolloDay技术开放日:文心大模型在自动驾驶感知中的落地应用

2数据处理大模型技术是自动驾驶行业近年的热议趋势&#xff0c;但能否落地应用、能否用好是关键难题。百度自动驾驶依托文心大模型特色优势&#xff0c;率先实现技术应用突破。百度自动驾驶技术专家王井东表示&#xff1a;文心大模型-图文弱监督预训练模型&#xff0c;背靠文心…

【PAT - 甲级1155】Heap Paths (30分)(栈,dfs,二叉树)

题干&#xff1a; In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (in a max heap) or less than or equal to…

TFS中的工作项(六)

TFS中的工作项 在VS中打开团队资源管理器 工作项有功能&#xff0c;产品积压工作项&#xff0c;任务&#xff0c;测试用例&#xff0c;Bug&#xff0c;障碍&#xff0c;它们之间的关系是&#xff1a;一个产品或应用&#xff0c;有一系列功能&#xff0c;功能最大&#xff0c;可…

单目3D物体检测模型(CaDDN): Categorical Depth Distribution Network for Monocular 3D Object Detection

本文介绍一篇单目3D物体检测模型&#xff1a;CaDDN&#xff0c;论文收录于 CVPR2021。 单目3D物体检测的主要挑战在于准确预测物体深度&#xff0c;由于缺乏直接的距离测量&#xff0c;因此必须根据物体和场景线索来推断物体深度。过去许多方法试图直接估计深度来辅助3D检测&am…