Codeup 5901: 【字符串】回文串

(字符串)回文串 (字符串)回文串 题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 12321 样例输出 YES /*回文串 思路:1.设置一个字符数组str用来存储字符串,str的长度为len; 2.回文字符串具有对称性,故只需扫描一半,判断str[i]是否等于str[n-1 阅读详情

题目描述

读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。

输入

一行字符串,长度不超过255。

输出

如果是回文串,输出“YES”,否则输出“NO”。

样例输入

12321

样例输出

YES
#include<cstdio>
#include<cstring> 
const int maxn=256;

bool judge(char str[])
{
	int len=strlen(str);
	for(int i=0;i<len/2;i++)
	{
		if(str[i]!=str[len-1-i]) return false;		
	}
	return true;	
}

int main()
{
	char str[maxn];
	while(gets(str))
	{
		if(judge(str)) printf("YES\n");
		else printf("NO\n");		
	}
	return 0;
}

 

OpenEuler22.03 LTS下Zabbix7.0监控系统的容器化部署避坑指南(含Docker-Compose完整配置) 本文详细介绍了在OpenEuler22.03 LTS操作系统上容器化部署Zabbix7.0监控系统的完整流程,包括Docker引擎配置、Docker-Compose编排、网络模式选择及性能调优等关键步骤。针对OpenEuler环境下的特殊问题提供了解决方案,帮助用户高效搭建稳定可靠的监控系统。 阅读详情

相关推荐

时间同步中 TOD 与GPRMC和IRIG-B的区别

时间同步中 TOD 与GPRMC和IRIG-B的区别

ftdlk的博客 1729

codeup5901【字符串】回文串

题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 12321 样例输出 YES 总结 1.C语言中使用EOF代表-1; 2.gets()函数的返回值为字符数组的首地址,能够读取空格,以回车作为字符串结束的标志,...

weixin_43370733的博客 355

数字IC后端实战:如何用ICC搞定复杂模块的floorplan与powerplan(附避坑指南)

本文深入解析数字IC后端设计中复杂模块的floorplan与powerplan实战技巧,重点介绍多边形模块边界处理、MTCMOS电源网络优化及存储器摆放陷阱规避。通过Synopsys ICC工具的具体操作示例和项目实战经验,帮助工程师高效解决设计难题,提升芯片性能与可靠性。

weixin_29213525的博客 352

C++实现回文串

C++实现回文串

weixin_59566851的博客 5765

Cyclone MAX独立编程实战:从硬件接口到SAP镜像的嵌入式烧录指南

在嵌入式系统开发与量产中,固件烧录是连接软件与硬件的关键环节。其核心原理是通过特定的调试接口(如JTAG、BDM)和编程算法,将编译后的机器码写入目标处理器的非易失性存储器。这项技术的价值在于确保软件在硬件上的可靠部署,是产品功能实现和质量保证的基础,广泛应用于汽车电子、工业控制等对一致性与可靠性要求极高的领域。独立编程器(Stand-Alone Programmer)在此基础上,通过集成存储、交互界面和任务逻辑,实现了脱离PC的自动化操作,极大提升了产线效率和现场维护的便捷性。本文以Cyclone MAX

weixin_34038293的博客 467

从零到一:TI AWR1843 Boost EVM与DCA1000 EVM的ADC数据采集实战指南

本文详细介绍了TI AWR1843 Boost EVM与DCA1000 EVM的ADC数据采集实战指南,涵盖硬件连接、软件配置、固件烧录、雷达参数设置及数据处理等关键步骤。通过MATLAB等工具,开发者可高效实现毫米波雷达数据采集,适用于自动驾驶、工业检测等领域。

weixin_29001327的博客 967

【手把手带你刷好题】—— 50.回文串(字符串)

【前言】 今天是刷题打卡第50天! 半百咯,加油加油。 原题:回文串(字符串) 题目描述: 读入一串字符,判断是否是“回文串”。“回文串” 是一个正读和反读都一样的字符串,比如“level” 或者 “noon” 就是回文串。 输入格式: 一行字符串,长度不超过255 输出格式: 如果是回文串,输出“YES”,否则输出“NO” 样例输入: 12321 样例输出: YES 思路: 假设字符串str 的下标是从0 开始的,由于“回文串” 是正读和...

安然无虞的博客 1449

ABAP 平台注册 OAuth 2.0 Client 的完整实践指南(覆盖 Authorization Code、SAML Bearer 与 PKCE)

本文详述了在ABAP平台上注册入站OAuth 2.0 Client的关键技术和操作要点。文章面向SAP技术人员,系统梳理了前置条件(TLS/SSL、技术用户、授权对象)、配置路径(SOAUTH2事务)、授权类型差异(授权码、SAML Bearer、PKCE)等重要内容。特别强调入站与出站配置的区别,并提供了保密客户端和公有客户端的配置指引。文中所有事务码和参数均参考SAP官方文档,包含多个实用案例和权限配置建议,为ABAP系统作为OAuth 2.0授权服务器的实施提供全面指导。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 298

codeup 5901 回文串

Problem I: 【字符串】回文串 Description 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 Input 一行字符串,长度不超过255。 Output 如果是回文串,输出“YES”,否则输出“NO”。 Sample Input 12321 Sample Output YES 算法: 不要想太多了,直接比较输入串的i与lenth-1-i比,比到二分之lenth就好了。 AC代码: #include<cstdi

蔡尼玛的博客 209

一文读懂 SAP ERP / SAP S/4HANA 里的 Price List:概念、配置、定价流程与可运行 ABAP 示例

SAP ERP/S4HANA中的Price List解析 本文系统阐述了SAP定价体系中Price List的核心概念和实现机制。Price List并非独立的价目表,而是通过条件技术(条件类型、访问序列、条件记录)与Price List Type(PLTYP)共同作用的定价维度。文章详细说明了: Price List本质上是客户主数据中的PLTYP字段,作为定价查找键使用 定价流程中条件访问序列如何利用PLTYP查找特定价格 S4HANA与ECC版本在价格维护入口的差异 实际业务中如何通过不同PLTYP实

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 663

斑马算法优化变分模态分解ZOA-VMD数字信号去噪(优化K值 alpha值)【含Matlab源码 4887期】

斑马算法优化变分模态分解ZOA-VMD数字信号去噪(优化K值 alpha值) 完整的代码,包运行;运行操作视频见优快云资源!适合小白!

订阅付费专栏Matlab(奶茶价版),可赠送奶茶价版付费专栏指定代码1份; 811

codeup 5901: 【字符串】回文串

5901: 【字符串】回文串 时间限制:1 Sec内存限制:128 MB 题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 ...

wuyaxin 213

顶级AI大模型白嫖ChatGPT Plus1个月,0成本薅顶配功能

Chat*** Plus限时免费1个月!原价20美元/月的顶配功能

BUG猿的博客 7289

Codeup——5901: 【字符串】回文串​​​​​​​

5901: 【字符串】回文串 时间限制:1 Sec内存限制:128 MB 题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 12321 样例输出 YES #include...

Yanir的博客 248

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

【Codeup】5901: 【字符串】回文串 解题报告

题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 12321 样例输出 YES 来源 题解 #include <cstdio> #include <strin...

wyatt007的博客 198

深度学习工具包 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")

codeup— 5901: 【字符串】回文串

题目链接:http://www.codeup.cn/problem.php?id=5901 题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 12321 样例输出 YES #inc...

Mongo_girl 257

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

codeUP 5901: 【字符串】回文串

思路 从字符串第一个字符和最后一个字符开始比较,不相同就不是回文。注意字符串长度奇偶。 源代码 #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; int main() { char a[256]; scanf("%s",a); int i,j = strlen(a)-1; for(i=0;i!...

YC_Jia的博客 319

codeup 5901 问题 I: 【字符串】回文串

题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 12321 样例输出 YES #include&lt;stdio.h&gt; #include&lt;string.h&gt; c...

水院天下第一 496

【codeup墓地】5901: 【字符串】回文串

原题链接 #include&lt;algorithm&gt; #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cstring&gt; #include &lt;ctime&gt; #include &lt;cmath&gt; #include &lt;vector&gt; #include &lt;set&gt

izhxxx的博客 214

3.6 字符串处理

字符串处理需要多想多积累多实践,下面列举书中的例题,以及以后峪道河字符串相关的题都直接放在这了。 PAT B1009 说反话 #include<iostream> #include<string> #include<vector> using namespace std; int main(){ vector<string> b; string a; while(cin>>a) //这里可以判断输入的末尾 b

qq_43784199的博客 116

Codeup5901-算法笔记顺序P95

时间限制: 1 Sec 内存限制: 128 MB读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。一行字符串,长度不超过255。如果是回文串,输出“YES”,否则输出“NO”。12321YES解题注意事项:水题,注意边界就好.

m0_63064861的博客 258

codeup-5901 判断回文串

题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 12321 样例输出 YES 代码(是《算法笔记》上的代码) #include <stdio.h> #include <...

像风一样. 228

字符串处理 [codeup 5901] 回文串

#include &lt;cstdio&gt; #include &lt;cstring&gt; const int maxn = 256;//先定义好最大值 bool isabc(char str[]){//main方法前写好要用的方法 int len = strlen(str); for(int i=0;i&lt;len/2;i++){ if(str[i]!=str[len-1...

让电脑能感受这美丽的世界 223

【codeup 5901】回文串

题目地址:http://www.codeup.cn/problem.php?cid=100000580&pid=8题目描述:读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。输入:一行字符串,长度不超过255。输出:如果是回文串,输出“YES”,否则输出“NO”。样例输入:12321样例输出:YES完整代码如下:#includ

一个程序员的成长之路。。。 487

【字符串】回文串 codeup5901

题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 12321 样例输出 YES 一开始这样写的,,虽然很繁琐zz,但感觉应该没错,然鹅没有通过~ #include<cstdio...

abcdefggggghk的博客 222

codeup 5901 | 回文串

5901: 【字符串】回文串 时间限制 : 1.000 sec内存限制 : 128 MB 题目描述 读入一串字符,判断是否是回文串。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。 输入 一行字符串,长度不超过255。 输出 如果是回文串,输出“YES”,否则输出“NO”。 样例输入 12321 样例输出 Y...

weixin_43787043的博客 273
上一篇: pat b1022 D进制的A+B
下一篇: PAT b1009 说反话
Estrellas_
博客等级 码龄9年 273粉丝 233原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值