Created
October 26, 2017 16:00
-
-
Save gooooloo/fc7acbf61c38f2b93252909c8d645e42 to your computer and use it in GitHub Desktop.
判断一个整数是不是回文数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(a): | |
a = abs(a) | |
b = a | |
c = 0 | |
while b > 0: | |
c = c * 10 + b % 10 | |
b //= 10 | |
print(c == a) | |
if __name__ == '__main__': | |
main(0) | |
main(3) | |
main(33) | |
main(343) | |
main(3443) | |
main(35) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment