当前位置:网站首页>实例030:回文数
实例030:回文数
2022-08-02 06:16:00 【懒笑翻】
题目:一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。
解题:
"""
学习中遇到问题没人解答?小编创建了一个Python学习交流QQ群,可扫文末的推广进群哦
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
"""
n = input("可以输入任意的数字:")
a = 0
b = len(n) - 1
flag = True # 用来标注是否是回文串
while a < b:
if n[a] != n[b]: # 判断对称位置的数是否相同 如果不相同则退出循环并不是回文串
print(n, '不是回文串')
flag = False
break
a, b = a + 1, b - 1
if flag:
print(n, '是回文串')结果:

边栏推荐
- Leetcode Weekly 304
- HCIP 第三天实验
- 有人开源全凭“为爱发电”,有人却用开源“搞到了钱”
- 解决C#非静态字段、方法或属性“islandnum.Program.getIslandCount(int[][], int, int)”要求对象引用
- (Part of it is not understood, and the notes are not completed) [Graph Theory] Difference Constraints
- Kind of weird!Access the destination URL, the host can container but not
- Project development specification
- MySQL高级-MVCC(超详细整理)
- 堡垒机、堡垒机的原理
- Pagoda+FastAdmin 404 Not Found
猜你喜欢
随机推荐
(Part of it is not understood, and the notes are not completed) [Graph Theory] Difference Constraints
Servlet
MySql -- 不存在则插入,存在则更新或忽略
Resolving C# non-static field, method or property "islandnum.Program.getIslandCount(int[][], int, int)" requires an object reference
2022年8月计划,着重ue4视频教程
PMP新考纲通关秘籍,告别抓瞎
HCIP 第二天
看图就懂|衡量业务增长健康的销售指标如何选择
.NET Static Code Weaving - Rougamo Release 1.1.0
MySQL高级-MVCC(超详细整理)
【暑期每日一题】洛谷 P1551 亲戚
MySQL Advanced - MVCC (ultra-detailed finishing)
How the Internet of Things is changing the efficiency of city operations
MySQL union query (multi-table query)
MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql
PHP Warning: putenv() has been disabled for security reasons in phar
数据库概论-MySQL的数据表的基本操作
MySQL Advanced Statements (1)
Summer Summary (3)
Unity Shader学习(七)纹理图像的简单使用








