1.7 编程基础之字符串 33 判断字符串是否为回文 python
生活随笔
收集整理的這篇文章主要介紹了
1.7 编程基础之字符串 33 判断字符串是否为回文 python
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http:// http://noi.openjudge.cn/ch0107/33/
"""1.7 編程基礎之字符串 33 判斷字符串是否為回文http://noi.openjudge.cn/ch0107/33/python判斷輸入字符串是否為回文 https://blog.csdn.net/happyuu/article/details/80731871Python案例:四種方法判斷回文字符串 https://howard2005.blog.csdn.net/article/details/108921500""" s = input("")rs = list(reversed(s))if list(s) == rs:print("yes")else:print("no")C++代碼:
/* 1.7編程基礎之字符串_33判斷字符串是否為回文07 http://noi.openjudge.cn/ch0107/33/ */ #include<iostream> using namespace std; int main() {string a;cin>>a;int k = a.length() ,b = k-1;for( int i = 0; i < k; i++){if(a[b] != a[i]){cout<<"no";return 0;}b--;} cout<<"yes";return 0; }總結
以上是生活随笔為你收集整理的1.7 编程基础之字符串 33 判断字符串是否为回文 python的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python批量替换目录下文件后缀脚本实
- 下一篇: js检测密码强度的功能实现逻辑思路及实例