本文共 706 字,大约阅读时间需要 2 分钟。
num = 10000sum = 0while num <= 99999: a = num % 10 b = num // 10000 c = num % 1000 // 10 d = (num - (num//10000)*10000)//1000 if a == b and c == d: print(num) sum += 1 num += 1print("5位数的回文数个数为:"sum)
执行结果:
1000111011120211303114041150511606117071180811909120002210122202223032240422505226062270722808229092300033101332023330333404335053360633707338083390934000441014420244303444044450544606447074480844909450005510155202553035540455505556065570755808559095600066101662026630366404665056660666707668086690967000771017720277303774047750577606777077780877909780008810188202883038840488505886068870788808889098900099101992029930399404995059960699707998089990995位数的回文数个数为: 90
转载地址:http://ggkwa.baihongyu.com/