回文正序和逆序一样的字符串,例如abccba
方法一
def is_palindrome1(text):
l = list(text)
()
t1 = ''.join(l)
if t1 == text:
print 'the text is palindrome'
else:
print 'the text is not palindrome'
方法二
def is_palindrome2(text):
t1 = text[::-1]
if t1 == text:
print 'the text is palindrome'
else:
print 'the text is not palindrome'
方法三
def is_palindrome3(text):
r = True
for x in range(len(text)):
print x,text[x]
if text[x] != text[len(text)-x-1]:
print 1
r = False
break
if r == True:
print 'the text is palindrome'
else:
print 'the text is not palindrome'
用递归方法判断字符串是否是回文(Recursion Palindrome Python)
所谓回文字符串,就是一个字符串从左到右读和从右到左读是完全一样的.比如:"level" .“aaabbaaa”. "madam"."radar&quo ...
AC日记——判断字符串是否为回文 openjudge 1.7 33
33:判断字符串是否为回文 总时间限制: 1000ms 内存限制: 65536kB 描述 输入一个字符串,输出该字符串是否回文.回文是指顺读和倒读都一样的字符串. 输入 输入为一行字符串(字符串中 ...
C#进行回文检测,判断字符串是否是回文的代码
下面代码内容是关于C#进行回文检测,判断字符串是否是回文的代码,应该是对各位朋友有些好处. ("算法1:请输入一个字符串!");string st ...
YTU 2802: 判断字符串是否为回文
2802: 判断字符串是否为回文 时间限制: 1 Sec 内存限制: 128 MB 提交: 348 解决: 246 题目描述 编写程序,判断输入的一个字符串是否为回文.若是则输出"Yes ...
Java - 判断字符串是否是回文
首先,回文是指类似于“12345”,“abcdcba”的形式,即正念和反念都是一样的字符串 判断字符串是否是回文,这边介绍3种办法 将字符串翻转,判断翻转后的字符串和原字符串是否相等 public s ...
C语言:判断字符串是否为回文,-函数fun将单向链表结点数据域为偶数的值累加起来。-用函数指针指向要调用的函数,并进行调用。
//函数fun功能:用函数指针指向要调用的函数,并进行调用. #include double f1(double x) { return x*x; } double f ...
type-of-python作业-判断字符串是否属于回文需要忽略其中的标点、空格与大小写
type-of-python作业 作业练习:要想检查文本是否属于回文需要忽略其中的标点.空格与大小写.例如,"Rise to vote, sir."是一段回文文本,但是我们现有的程 ...
Java判断一个字符串是否是回文
package ; /** * 判断字符串是否为回文 * * @author liuwenlong * @create 2020-08-31 11:33:04 */ @S ...
javascript判断给定字符串是否是回文
//判断给定字符串是否是回文 function isPalindrome(word) { var s = new Stack(); for (var i = 0 ...
随机推荐
gradle 如何操作命令行
如题: 官方做法: task startApp(type: Exec){task -> workingDir mWorkingDirRoot commandLine 'cd'} 后来我看到这篇文 ...
TextView 设置超过几行后显示省略号
android:lines="5" android:ellipsize="end"
安装Oracle11后在SQL Developer启动时提示:enter the full pathname for the java.exe
1) Open the file ..\sqldeveloper\sqldeveloper\bin\ and add the following line to se ...
Windows Server时间服务器配置方法
1 时间服务器经常会碰到客户端机器需要和服务器在时间上保持同步,否则会出现各种问题,特别是有时间相关的触发功能的时候. 为解决各设备间时间统一的问题,我们可在网络中设置一台服务器使其作为基准时间,其它 ...
第九章:Python の 网络编程基础(一)
本課主題 何为TCP/IP协议 初认识什么是网络编程 网络编程中的 "粘包" 自定义 MySocket 类 本周作业 何为TCP/IP 协议 TCP/IP协议是主机接入互网以及接入 ...
jqGrid 手册 - 搜索
搜索 类型: colModel Options Toolbar Searching Custom Searching Single field searching Advanced Searching ...
safari图片跨域
/renfufei/article/details/51675148
js 数组里面任意两个数的和与目标值
...OpenCV resources
/small_foxrabbit/article/details/39858149http:///wuyoy520/article/d ...