{"id":6471,"date":"2022-06-05T00:33:50","date_gmt":"2022-06-04T16:33:50","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=6471"},"modified":"2024-05-05T14:18:54","modified_gmt":"2024-05-05T06:18:54","slug":"%e5%9b%9e%e6%96%87%e6%95%b0","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=6471","title":{"rendered":"\u56de\u6587\u6570"},"content":{"rendered":"\n<p class=\"has-text-align-center\">\u9898\u76ee<\/p>\n\n\n\n<p>\u7ed9\u4f60\u4e00\u4e2a\u6574\u6570 x \uff0c\u5982\u679c x \u662f\u4e00\u4e2a\u56de\u6587\u6574\u6570\uff0c\u8fd4\u56de true \uff1b\u5426\u5219\uff0c\u8fd4\u56de false \u3002<\/p>\n\n\n\n<p>\u56de\u6587\u6570\u662f\u6307\u6b63\u5e8f\uff08\u4ece\u5de6\u5411\u53f3\uff09\u548c\u5012\u5e8f\uff08\u4ece\u53f3\u5411\u5de6\uff09\u8bfb\u90fd\u662f\u4e00\u6837\u7684\u6574\u6570\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c121 \u662f\u56de\u6587\uff0c\u800c 123 \u4e0d\u662f\u3002<\/p>\n\n\n\n<p>\u6765\u6e90\uff1a\u529b\u6263\uff08LeetCode\uff09<br>\u94fe\u63a5\uff1ahttps:\/\/leetcode.cn\/problems\/palindrome-number<br>\u8457\u4f5c\u6743\u5f52\u9886\u6263\u7f51\u7edc\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u5b98\u65b9\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center\">\u601d\u8def<\/p>\n\n\n\n<p>1.\u8d1f\u6570\u4e0d\u662f\u56de\u6587\u6570\uff0c\u76f4\u63a5\u6392\u9664\u3002<\/p>\n\n\n\n<p>2.\u96f6\u662f\u56de\u6587\u6570\uff0c\u76f4\u63a5\u786e\u5b9a\u3002<\/p>\n\n\n\n<p>3.\u5728\u4e0d\u662f 0 \u7684\u60c5\u51b5\u4e0b\uff0c\u4ee5 0 \u7ed3\u5c3e\u7684\u6570\u4e0d\u662f\u56de\u6587\u6570\uff0c\u5982 1230 \u5012\u5e8f\u540e\u4e3a 321\uff0c\u5c31\u662f\u5224\u65ad\u662f\u5426\u80fd\u88ab 10 \u6574\u9664\u3002<\/p>\n\n\n\n<p>4.\u5728\u6392\u9664\u524d\u9762\u7684\u60c5\u51b5\u540e\uff0c\u5c31\u662f\u5c06\u539f\u6570\u4e0e\u5012\u5e8f\u540e\u7684\u6570\u6bd4\u8f83\uff0c\u76f8\u7b49\u5c31\u662f\u56de\u6587\u6570\u3002\u73b0\u5728\u7684\u5173\u952e\u70b9\u5c31\u5728\u5012\u5e8f\u4e0a\uff0c\u53ef\u4ee5\u5c06\u6570\u5b57\u8f6c\u4e3a\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u5012\u5e8f\uff1b\u4e5f\u53ef\u4ee5\u76f4\u63a5\u57fa\u4e8e\u6570\u5b57\u5904\u7406\u8fdb\u884c\u5012\u5e8f\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center\">\u4ee3\u7801<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u6570\u5b57\u5904\u7406<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bool isPalindrome(int x)\n{\n    if (x &lt; 0)\n    {\n        return false;\n    }\n    else if (x == 0)\n    {\n        return true;\n    }\n    else if (x % 10 == 0)\n    {\n        return false;\n    }\n\n    unsigned int reverse = 0;\n    int src = x;\n    while (x)\n    {\n        reverse *= 10;\n        reverse += (x % 10);\n        x \/= 10;\n    }\n    \n    if (reverse == src)\n    {\n        return true;\n    }\n    return false;\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"415\" height=\"152\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/06\/image-11.png\" alt=\"\" class=\"wp-image-6472 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/06\/image-11.png 415w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/06\/image-11-300x110.png 300w\" data-sizes=\"(max-width: 415px) 100vw, 415px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 415px; --smush-placeholder-aspect-ratio: 415\/152;\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5b57\u7b26\u4e32\u5904\u7406<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;stdio.h>\n#include &lt;string.h>\n\nbool isPalindrome(int x)\n{\n    if (x &lt; 0)\n    {\n        return false;\n    }\n    else if (x == 0)\n    {\n        return true;\n    }\n    else if (x % 10 == 0)\n    {\n        return false;\n    }\n\n    static char src[11], reverse[11];\n    memset(src, '\\0', sizeof(src));\n    memset(reverse, '\\0', sizeof(reverse));\n    sprintf(src, \"%d\", x);\n    \n    for (int i = 9, j = 0; i >= 0; --i)\n    {\n        if (src[i] == '\\0')\n        {\n            continue;\n        }\n        reverse[j] = src[i];\n        ++j;\n    }\n\n    if (strcmp(src, reverse) == 0)\n    {\n        return true;\n    }\n    return false;\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"401\" height=\"137\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/06\/image-12.png\" alt=\"\" class=\"wp-image-6473 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/06\/image-12.png 401w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/06\/image-12-300x102.png 300w\" data-sizes=\"(max-width: 401px) 100vw, 401px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 401px; --smush-placeholder-aspect-ratio: 401\/137;\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee \u7ed9\u4f60\u4e00\u4e2a\u6574\u6570 x \uff0c\u5982\u679c x \u662f\u4e00\u4e2a\u56de\u6587\u6574\u6570\uff0c\u8fd4\u56de true \uff1b\u5426\u5219\uff0c\u8fd4\u56de false \u3002 \u56de\u6587\u6570\u662f\u6307\u6b63 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-6471","post","type-post","status-publish","format-standard","hentry","category-all"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/6471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6471"}],"version-history":[{"count":0,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/6471\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}