爆刷PAT(甲级)——之【1005】 Spell It Right (20)——英文加法,C++

【HALCON工业视觉应用探索】02. C# + Halcon铸件毛刺机器人打磨引导:点云处理从实验室到工业现场的全流程落地 摘要:铸件毛刺的自动化打磨是机械制造领域的重要难题,其随机性(高度0.1-3mm)和复杂工况导致人工打磨效率低(3分钟/件)、工伤率高。本文基于Halcon 24.11与.NET 6,构建了一套点云处理方案:通过线激光扫描仪获取三维点云,经预处理、毛刺检测、路径规划三大模块,引导机器人完成打磨。虚拟实验测试显示,对高度>1mm的毛刺检出率达100%,定位误差±0.08mm,但工业现场受油污、粉尘影响,性能降至检出率68-75%、处理时间>45秒。 阅读详情

题意:给一个100位的数字串,给出数字串上各数字和的英文弱智版本翻译。

什么叫弱智版本翻译,就是 “15”  只要翻译  “one five”就可以了。。。。。

难点: 100位的数字串,全是9那和就是900最大了,最多只要输出3个英文单词。大一级别的题目,毫无难点的手速题。

 

看来PAT不是按照题目难度排序。。。

Code:

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define inf 109
#define INF 0x3f3f3f3f
#define loop(x,y,z) for(x=y;x<z;x++)

char s[inf];
int len,num[5];
string words[11]={"zero","one","two","three","four",
"five","six","seven","eight","nine"};

void Input()
{
    cin>>s;
}

void Solve()
{
    len=strlen(s);//字符串长度
    int i,sum=0;
    loop(i,0,len)sum+=s[i]-48;
    len=0;//输出长度
    while(sum!=0)
    {
        num[len++]=sum%10;
        sum/=10;
    }
}

void Output()
{
    int i;
    for(i=len-1;i>0;i--)//存的时候是倒序的,个位在前,所以要倒序输出
        cout<<words[num[i]]<<" ";
    cout<<words[num[i]]<<endl;
}

int main()
{
    Input();
    Solve();
    Output();
    return 0;
}

 

深度学习实战103-基于KDD Cup 99数据集的搭建神经网络的检测系统(NIDS),通过对网络流量数据进行分析,提供完整代码 接下来,我们定义一个全连接神经网络模型。return x# 创建数据集和数据加载器# 初始化模型通过以上步骤,我们实现了一个基于PyTorch的简单网络入侵检测系统。这个系统使用KDD Cup 99数据集进行训练和评估。实际应用中,您可以根据需求调整模型结构、超参数以及数据预处理方法。希望对大家有所帮助!如果有任何问题或需要进一步的解释,请随时咨询。 阅读详情

相关推荐

让Qt程序适配高分辨率屏幕,解决软件界面错乱异常

前期使用Qt开发一个登录模块一直使用很好。最近在一台新电脑上使用时发现排版混乱。这个问题很普遍,主要原因是旧软件对高清显示器的适配不当造成的。新电脑使用的是4K屏,win10系统自动进行了175%的缩放。

cihron的博客 1万+

PAT甲级 英文词组翻译

数据的要求 standard format 标准格式 a pair of 一双(一般是每组测试有两个数) rearrange 重新排列 数据描述 polynomial 多项式 exponent 指数 coefficient 系数 respectively 依次为...

成长日记的博客 757

PLC控制气缸与电磁阀:从原理到实战编程详解

在工业自动化领域,很多工程师都能编写PLC程序控制电机启停,但当涉及到气缸和电磁阀的精确控制时,却常常遇到动作不协调、响应延迟甚至设备损坏的问题。这背后的关键不在于PLC编程本身,而在于对气动元件特性和控制逻辑的深入理解。 本文将从实际工程问题出发,深入解析气缸与电磁阀的工作原理、PLC控制逻辑设计、常见故障排查方法,并通过完整的梯形图实例,帮助读者掌握气动系统自动化编程的核心要点。无论你是刚接触PLC的初学者,还是希望提升气动控制技能的工程师,都能从中获得实用的技术指导。 1. 气缸与电磁阀在自动化控制中

weixin_42522374的博客 337

N Queens(NOIOPJENGLISH06)

翻译题6

chinojiang的博客 256

爬取百度图片

最开始,我们想要爬取图片,首先需要打开百度图库,然后在搜索栏中输入自己想要的图片(比如说壁纸)。接着右键检查,点击网络:起初可能没有名称信息,刷新界面就可以了。打开信息,查看标头内容可以看到请求URL为:复制这串URL,然后在浏览器中打开这个就是我们搜索的壁纸图片的网页内容。怎么找到图片的URL呢?在上述内容中,找到data,可以发现里面每隔一个aiEditData,下面代码的形式是一样的,就相当于一张图片。

weixin_54143563的博客 1939

【论文复现】自动化细胞核分割与特征分析

HoVer-Net是一种精心设计的多分支深度学习网络架构,专为处理复杂的多组织显微图像中的细胞核实例分割与精确分类任务而开发。该网络通过创新的策略,不仅有效解决了细胞核在密集聚集区域难以准确区分的问题,还实现了对每个独立细胞核类型的细致分类。此外,HoVer-Net还引入了专门的上采样分支,这一设计旨在对每个成功分割出的细胞核实例进行进一步的核类型分类。这一分支利用高级语义信息,结合精心设计的分类策略,能够准确判断每个细胞核的所属类型,为医学研究提供了宝贵的细胞水平信息。

2201_75366661的博客 1978

PAT甲级英文

老规矩: hence indices

ChangeW fafa的博客 624

如何从RHEL 8升级到RHEL 9

Red Hat 于 2022 年 5 月 17 日宣布全面推出 RHEL 9。这是 RHEL(Red Hat Enterprise Linux)的最新版本,它具有许多功能和增强功能。

u012748257的博客 1019

2019年4月6日学习总结

我的电脑不知道抽了啥风,又坏了,怎么也连不上网了,我修了半晚上也没修好所以博客是用室友的电脑写的。 因为之前高中室友老早就说好来找我玩,都约好了,也不好推拒,所以体验赛也没能和队友一起打,晚上回来看了下体验赛的题,题目许多也并不是特别难,主要是考思路。只要想出来思路,代码写起来比较简单。有许多代码写起来都非常短小,有的都不超过10行,主要是思路。把每个代码题都转化成数学题,用数学的思路把题解出来再...

No Pain, No Gain . 303

Cadence SIP Layout 简单教程-第一章

以摄像头模组软硬结合板为例,描述layout的整个完整过程,从而掌握基本技能。 第一章 准备工作 第一节 原理图不用说layout前需要绘制原理图,原理图不在本文讨论范围内,所以列为准备工作。 需要特别说明的是,绘制原理的最终目的是导出网络表,网络表中的重要参数footprint是让layout软件选择正确封装的关键,所以这里讲解一下原理图设置footprint的位置。在原理图中双击零件,...

whp1920的博客 1万+

C/C++李峋同款跳动的爱心代码(完整代码)

C++语言实现出李峋同款跳动的爱心的完整代码。

AIGC 10万+

C++英文单词统计小程序

//WorldTest.h /* //Function : count world //Date : 2015-09-24 //Author : pengl */ #ifndef _WORLD_TEST_H_ #define _WORLD_TEST_H_ #include #include #include #include #include #include #include

JUSTACES 的博客 3516

科研项目数据抓取:Python爬虫实现与分析

本文详细介绍了如何使用Python爬虫抓取科研项目的数据,涵盖了从目标数据源选择到数据存储与分析的整个过程。通过使用。

2201_76125261的博客 1710

PAT甲级 1005 Spell It Right

PAT甲级 1005 Spell It Right 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 con...

旺崽的博客 2907

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

【PAT甲级 - C++题解】1005 Spell It Right

📣专栏定位:为想考甲级PAT的小伙伴整理常考算法题解,祝大家都能取得满分!

Newin2020的博客 726

WINCC7.3破解文件

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

PAT 甲级题目讲解:1005《Spell It Right》

本文讲解 PAT 甲级 1005 题《Spell It Right》的完整解题思路与 C++ 实现。题目要求对最多 100 位的非负整数求数位和,并将和的每一位以英文单词输出。文章分三步展开:字符串读取与特判、数位求和、数字拆解与英文映射输出,并附完整代码、常见错误提醒及复杂度分析,适合备考 PAT 甲级的读者参考。

qq_35624947的博客 457

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

【PAT甲级】1005 Spell It Right (20 分)

Spell It Right 题目描述 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 ...

初见还是重逢的博客 279

PAT(甲级) 1005 Spell It Right (20分)

题目来源: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: ...

sinat_41835935的博客 165

PAT甲级-1005 Spell It Right (20分)

点击链接PAT甲级-AC全解汇总 题目: 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...

卷子的博客 504

PAT甲级 - 1005 Spell It Right (20 分)

题目链接: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: Ea...

450

「PAT甲级真题解析」Advanced Level 1005 Spell It Right

题设明确要求我们将给定的一个非负数的各个数字相加求和, 然后输出这个和各个数字的英文形式, 妥妥的模拟题, 而且步骤已经非常明确。 需要考虑的是给定的非负数最大可以是10^100(101位, 1个一后面跟了100个零), 所以需要用字符串来存储整数.

过美好生活,做高效程序员 5223

[PAT 甲级] 1005 Spell It Right (20 分)

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

cp0328的博客 3332

PAT甲级1005 Spell it Right 【20】【字符串操作】

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: 给出一个非负整数N,你的任务是计算所有N的数位数字之和,然后将这个和的每一个数位都用英语表示出来。 Each input file cont

Cambridge26的博客 3656

PAT 甲级 1005 Spell It Right (20 分)

题目:PAT 甲级 1005 Spell It Right (20 分) 经验总结: 由于输入的数据可能是100位的数字,所以得用字符串来存储这个数字,然后字符串模拟相加。 可以使用一个字符串数组用于存放0~9的数字的英文,然后用栈存放这些英文,最后用栈输出。 记:一定要注意0的情况。 C++代码: #include<bits/stdc++.h> using namespace...

努力努力再努力 142

PAT甲级 1005 Spell It Right (20 分) C++题解

\quad这是一个字符串处理题,目的是输入一个字符串,输出这个字符串中各个数之和对应的数中每一位数字的英文单词。分为以下三步: 求出一个字符串中各个数之和sum 将sum分解为各个数字,保存在vector中 按照顺序输出vector中每个数字对应的英文单词 #include <iostream> #include <stdio.h> #include <strin...

qq_40438165的博客 1471

# PAT甲级1005 Spell It Right (20分)

PAT甲级1005 Spell It Right (20分) 题目: 题目描述:比较简单的一个字符串问题,10分钟搞定,记得输入的时候用cin并且用string类型,否则会报错,20分的字符串问题还是比较简单鸭,good night~~~ #include <iostream> #include <cstdio> #include <algorithm> #in...

weixin_43795683的博客 161
上一篇: 爆刷PAT(甲级)——之【1004】 Counting Leaves (30)——树上简单dfs搜索
下一篇: 爆刷PAT(甲级)——之【1006】Sign In and Sign Out (25)——简单排序,C++
仰天倀笑
博客等级 码龄10年 313粉丝 124原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值