{"id":370,"date":"2018-11-22T17:05:32","date_gmt":"2018-11-22T09:05:32","guid":{"rendered":"https:\/\/blog.tcreopargh.xyz\/?p=370"},"modified":"2019-01-04T19:30:43","modified_gmt":"2019-01-04T11:30:43","slug":"c%e6%95%b0%e5%ad%97%e6%8f%90%e5%8f%96","status":"publish","type":"post","link":"https:\/\/blog.tcreopargh.xyz\/?p=370","title":{"rendered":"(C++)\u6570\u5b57\u63d0\u53d6"},"content":{"rendered":"\n<div class=\"mdui-panel mdui-panel-gapless\" mdui-panel>\n    <div class=\"mdui-panel-item mdui-panel-item-open\">\n      <div class=\"mdui-panel-item-header\">\n        <div class=\"mdui-panel-item-title\"><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/div>\n        <i class=\"mdui-panel-item-arrow mdui-icon material-icons\">keyboard_arrow_down<\/i>\n      <\/div>\n      <div class=\"mdui-panel-item-body\">\n        <p>\u7f16\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u4ece\u952e\u76d8\u4e0d\u65ad\u8f93\u5165\u5b57\u7b26\u4e32\uff0c\u4ece\u5de6\u81f3\u53f3\u63d0\u53d6\u51fa\u8be5\u5b57\u7b26\u4e32\u7684\u6570\u5b57\uff0c\u5e76\u6c42\u51fa\u62fc\u51d1\u800c\u6210\u7684\u6570\u5b57[\u7684\u6700\u5927\u56e0\u6570\uff08\u82e5\u6570\u5b57\u4e3a\u8d28\u6570\uff0c\u5219\u8f93\u51fa\u6570\u5b57\u672c\u8eab\uff0c\u82e5\u5b57\u7b26\u4e32\u4e2d\u4e0d\u542b\u6570\u5b57\uff0c\u8f93\u51fa0\uff09<\/p>\n      <\/div>\n    <\/div>\n  <\/div>\n\n\n\n<div class=\"mdui-panel mdui-panel-gapless\" mdui-panel>\n    <div class=\"mdui-panel-item mdui-panel-item-open\">\n      <div class=\"mdui-panel-item-header\">\n        <div class=\"mdui-panel-item-title\"><strong>\u8f93\u5165\u8bf4\u660e<\/strong><\/div>\n        <i class=\"mdui-panel-item-arrow mdui-icon material-icons\">keyboard_arrow_down<\/i>\n      <\/div>\n      <div class=\"mdui-panel-item-body\">\n        <p>\u591a\u7ec4\u6570\u636e\uff0c\u6bcf\u884c\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u8f93\u5165\u7a7a\u7684\u4e00\u884c\u8868\u793a\u8f93\u5165\u7ed3\u675f\u3002<\/p>\n      <\/div>\n    <\/div>\n  <\/div>\n\n\n\n<div class=\"mdui-panel mdui-panel-gapless\" mdui-panel>\n    <div class=\"mdui-panel-item mdui-panel-item-open\">\n      <div class=\"mdui-panel-item-header\">\n        <div class=\"mdui-panel-item-title\"><strong>\u8f93\u51fa\u8bf4\u660e<\/strong><\/div>\n        <i class=\"mdui-panel-item-arrow mdui-icon material-icons\">keyboard_arrow_down<\/i>\n      <\/div>\n      <div class=\"mdui-panel-item-body\">\n        <p>\u8f93\u51fa\u6bcf\u4e2a\u5b57\u7b26\u4e32\u63d0\u53d6\u51fa\u6570\u5b57\u7684\u6700\u5927\u56e0\u6570\uff0c\u6362\u884c\u3002\u82e5\u6570\u5b57\u4e3a\u8d28\u6570\uff0c\u5219\u8f93\u51fa\u6570\u5b57\u672c\u8eab\uff0c\u82e5\u5b57\u7b26\u4e32\u4e2d\u4e0d\u542b\u6570\u5b57\uff0c\u8f93\u51fa0\u3002 <\/p>\n      <\/div>\n    <\/div>\n  <\/div>\n\n\n\n<div class=\"mdui-panel mdui-panel-gapless\" mdui-panel>\n    <div class=\"mdui-panel-item mdui-panel-item-open\">\n      <div class=\"mdui-panel-item-header\">\n        <div class=\"mdui-panel-item-title\"><strong>\u8f93\u5165\u6837\u4f8b<\/strong><\/div>\n        <i class=\"mdui-panel-item-arrow mdui-icon material-icons\">keyboard_arrow_down<\/i>\n      <\/div>\n      <div class=\"mdui-panel-item-body\">\n        <p>Xiaoming has 97 yuan<\/p>\n\n\n\n<p>saf3#$%d6a&amp;GO9I)LK$<\/p>\n\n\n\n<p>NONUMBERS<\/p>\n      <\/div>\n    <\/div>\n  <\/div>\n\n\n\n<div class=\"mdui-panel mdui-panel-gapless\" mdui-panel>\n    <div class=\"mdui-panel-item mdui-panel-item-open\">\n      <div class=\"mdui-panel-item-header\">\n        <div class=\"mdui-panel-item-title\"><strong>\u8f93\u51fa\u6837\u4f8b<\/strong><\/div>\n        <i class=\"mdui-panel-item-arrow mdui-icon material-icons\">keyboard_arrow_down<\/i>\n      <\/div>\n      <div class=\"mdui-panel-item-body\">\n        <p>97<\/p>\n\n\n\n<p>123<\/p>\n\n\n\n<p>0<\/p>\n      <\/div>\n    <\/div>\n  <\/div>\n\n\n\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n\n\n\n\n<div class=\"codecolorer-container cpp default\" style=\"overflow:auto;white-space:nowrap;width:958px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/><\/div><\/td><td><div class=\"cpp codecolorer\"><span class=\"co2\">#include&lt;string&gt;<\/span><br \/>\n<span class=\"co2\">#include&lt;cstring&gt;<\/span><br \/>\n<span class=\"co2\">#include&lt;cstdio&gt;<\/span><br \/>\n<span class=\"co2\">#include&lt;iostream&gt;<\/span><br \/>\n<span class=\"co2\">#include&lt;cmath&gt;<\/span><br \/>\n<span class=\"kw2\">using<\/span> <span class=\"kw2\">namespace<\/span> std<span class=\"sy4\">;<\/span><br \/>\n<span class=\"kw4\">int<\/span> main<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">while<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw2\">true<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; string s<span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw4\">int<\/span> num<span class=\"sy1\">=<\/span><span class=\"nu0\">0<\/span><span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw4\">char<\/span> <span class=\"sy2\">*<\/span>snum<span class=\"sy1\">=<\/span><span class=\"kw3\">new<\/span> <span class=\"kw4\">char<\/span><span class=\"br0\">&#91;<\/span><span class=\"nu0\">1000<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; getline<span class=\"br0\">&#40;<\/span><span class=\"kw3\">cin<\/span>,s<span class=\"br0\">&#41;<\/span><span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span>s<span class=\"sy1\">==<\/span><span class=\"st0\">&quot;&quot;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">break<\/span><span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw4\">int<\/span> j<span class=\"sy1\">=<\/span><span class=\"nu0\">0<\/span>,res<span class=\"sy1\">=<\/span><span class=\"nu0\">0<\/span><span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">for<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw4\">unsigned<\/span> <span class=\"kw4\">int<\/span> i<span class=\"sy1\">=<\/span><span class=\"nu0\">0<\/span><span class=\"sy4\">;<\/span> i<span class=\"sy1\">&lt;<\/span>s.<span class=\"me1\">size<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy4\">;<\/span> i<span class=\"sy2\">++<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span>s.<span class=\"me1\">at<\/span><span class=\"br0\">&#40;<\/span>i<span class=\"br0\">&#41;<\/span><span class=\"sy1\">&lt;=<\/span><span class=\"st0\">'9'<\/span><span class=\"sy3\">&amp;&amp;<\/span>s.<span class=\"me1\">at<\/span><span class=\"br0\">&#40;<\/span>i<span class=\"br0\">&#41;<\/span><span class=\"sy1\">&gt;=<\/span><span class=\"st0\">'0'<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; snum<span class=\"br0\">&#91;<\/span>j<span class=\"br0\">&#93;<\/span><span class=\"sy1\">=<\/span>s.<span class=\"me1\">at<\/span><span class=\"br0\">&#40;<\/span>i<span class=\"br0\">&#41;<\/span><span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j<span class=\"sy2\">++<\/span><span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw3\">sscanf<\/span><span class=\"br0\">&#40;<\/span>snum,<span class=\"st0\">&quot;%d&quot;<\/span>,<span class=\"sy3\">&amp;<\/span>num<span class=\"br0\">&#41;<\/span><span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">for<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw4\">int<\/span> i<span class=\"sy1\">=<\/span><span class=\"nu0\">2<\/span><span class=\"sy4\">;<\/span> i<span class=\"sy1\">&lt;=<\/span><span class=\"kw3\">sqrt<\/span><span class=\"br0\">&#40;<\/span>num<span class=\"br0\">&#41;<\/span><span class=\"sy4\">;<\/span> i<span class=\"sy2\">++<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span>num<span class=\"sy2\">%<\/span>i<span class=\"sy1\">==<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res<span class=\"sy1\">=<\/span>num<span class=\"sy2\">\/<\/span>i<span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">break<\/span><span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span>res<span class=\"sy1\">==<\/span><span class=\"nu0\">1<\/span><span class=\"sy3\">||<\/span>num<span class=\"sy1\">==<\/span><span class=\"nu0\">1<\/span><span class=\"sy3\">||<\/span>res<span class=\"sy1\">==<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw3\">cout<\/span><span class=\"sy1\">&lt;&lt;<\/span>num<span class=\"sy1\">&lt;&lt;<\/span>endl<span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">else<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw3\">cout<\/span><span class=\"sy1\">&lt;&lt;<\/span>res<span class=\"sy1\">&lt;&lt;<\/span>endl<span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw3\">delete<\/span> <span class=\"br0\">&#91;<\/span><span class=\"br0\">&#93;<\/span>snum<span class=\"sy4\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">return<\/span> <span class=\"nu0\">0<\/span><span class=\"sy4\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>\u4ee3\u7801\u5982\u4e0b: 1234567891011121314151617181920212223242526272829 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":372,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,7,32,10],"tags":[37,42,16,38],"_links":{"self":[{"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=\/wp\/v2\/posts\/370"}],"collection":[{"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=370"}],"version-history":[{"count":3,"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=\/wp\/v2\/posts\/370\/revisions"}],"predecessor-version":[{"id":475,"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=\/wp\/v2\/posts\/370\/revisions\/475"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=\/wp\/v2\/media\/372"}],"wp:attachment":[{"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.tcreopargh.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}