{"id":1270,"date":"2026-05-03T12:01:13","date_gmt":"2026-05-03T04:01:13","guid":{"rendered":"http:\/\/wordpress.fangt.online\/?p=1270"},"modified":"2026-05-03T12:01:13","modified_gmt":"2026-05-03T04:01:13","slug":"%e5%b8%b8%e7%94%a8%e8%87%aa%e5%b8%a6%e5%b7%a5%e5%85%b7%ef%bc%88%e5%87%bd%e6%95%b0%ef%bc%89","status":"publish","type":"post","link":"http:\/\/wordpress.fangt.online\/index.php\/2026\/05\/03\/%e5%b8%b8%e7%94%a8%e8%87%aa%e5%b8%a6%e5%b7%a5%e5%85%b7%ef%bc%88%e5%87%bd%e6%95%b0%ef%bc%89\/","title":{"rendered":"\u5e38\u7528\u81ea\u5e26\u5de5\u5177\uff08\u51fd\u6570\uff09"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u4e00\u3001\u6bd4\u8f83\u51fd\u6570<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>min(a, b)<\/strong> &#8211; \u8fd4\u56de\u6700\u5c0f\u503c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include &lt;algorithm&gt;<br>&nbsp;int a = 5, b = 10;<br>&nbsp;int smaller = min(a, b); &nbsp;\/\/ \u8fd4\u56de5<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>max(a, b)<\/strong> &#8211; \u8fd4\u56de\u6700\u5927\u503c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include &lt;algorithm&gt;<br>&nbsp;int a = 5, b = 10;<br>&nbsp;int larger = max(a, b); &nbsp; \/\/ \u8fd4\u56de10<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6269\u5c55\u7528\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;min({a, b, c, d}); &nbsp; &nbsp; &nbsp;\/\/ \u8fd4\u56de\u6700\u5c0f\u503c<br>&nbsp;max({a, b, c, d}); &nbsp; &nbsp; &nbsp;\/\/ \u8fd4\u56de\u6700\u5927\u503c<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e8c\u3001\u4ea4\u6362\u51fd\u6570<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>swap(a, b)<\/strong> &#8211; \u4ea4\u6362\u4e24\u4e2a\u503c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include &lt;utility&gt; &nbsp;\/\/ \u6216 &lt;algorithm&gt;<br>&nbsp;int x = 5, y = 10;<br>&nbsp;swap(x, y); &nbsp;\/\/ x=10, y=5<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u6570\u5b66\u51fd\u6570<code>&lt;cmath&gt;<\/code><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. \u7edd\u5bf9\u503c<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;\/\/ \u6574\u6570\u7edd\u5bf9\u503c<br>&nbsp;int a = -5;<br>&nbsp;int abs_a = abs(a); &nbsp; &nbsp; &nbsp;<br>&nbsp;\u200b<br>&nbsp;\/\/ \u6d6e\u70b9\u6570\u7edd\u5bf9\u503c<br>&nbsp;double b = -3.14;<br>&nbsp;double abs_b = abs(b); &nbsp;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. \u5e73\u65b9\u6839 &#8211; sqrt(a)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;double x = 16.0;<br>&nbsp;double root = sqrt(x); &nbsp;\/\/ 4.0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. \u7acb\u65b9\u6839 &#8211; cbrt(a)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;double x = 27.0;<br>&nbsp;double root = cbrt(x); &nbsp;\/\/ 3.0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. \u6c42\u5e42 &#8211; pow(a, b)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;double a = 2.0, b = 3.0;<br>&nbsp;double result = pow(a, b); &nbsp;\/\/ 8.0 (2\u00b3)<br>&nbsp;\u200b<br>&nbsp;\/\/ \u5b9e\u9645\u5e94\u7528\uff1a<br>&nbsp;pow(10, 2) &nbsp; &nbsp;\/\/ 100.0<br>&nbsp;pow(2, 0.5) &nbsp; \/\/ \u221a2 \u2248 1.414<br>&nbsp;pow(4, -1) &nbsp; &nbsp;\/\/ 0.25 (4\u207b\u00b9)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u56db\u3001\u53d6\u6574\u51fd\u6570<code>&lt;cmath&gt;<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. ceil(a)<\/strong> &#8211; \u5411\u4e0a\u53d6\u6574<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include <br>&nbsp;ceil(3.2) &nbsp; \/\/ 4.0<br>&nbsp;ceil(-3.2) &nbsp;\/\/ -3.0<br>&nbsp;ceil(3.0) &nbsp; \/\/ 3.0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. floor(a)<\/strong> &#8211; \u5411\u4e0b\u53d6\u6574<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include &lt;cmath&gt;<br>&nbsp;floor(3.8) &nbsp; \/\/ 3.0<br>&nbsp;floor(-3.8) &nbsp;\/\/ -4.0<br>&nbsp;floor(3.0) &nbsp; \/\/ 3.0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. round(a)<\/strong> &#8211; \u56db\u820d\u4e94\u5165<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include &lt;cmath&gt;<br>&nbsp;round(3.4) &nbsp; \/\/ 3.0<br>&nbsp;round(3.5) &nbsp; \/\/ 4.0<br>&nbsp;round(-3.5) &nbsp;\/\/ -4.0 (\u4e2d\u95f4\u503c\u5411\u8fdc\u79bb0\u65b9\u5411\u820d\u5165)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. trunc(a)<\/strong> &#8211; \u622a\u65ad\u5c0f\u6570\u90e8\u5206\uff08\u54110\u53d6\u6574\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include &lt;cmath&gt;<br>&nbsp;trunc(3.7) &nbsp; \/\/ 3.0<br>&nbsp;trunc(-3.7) &nbsp;\/\/ -3.0<br>&nbsp;trunc(3.0) &nbsp; \/\/ 3.0<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b9e\u7528\u793a\u4f8b<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b1\uff1a\u6700\u5927\u516c\u7ea6\u6570\u548c\u6700\u5c0f\u516c\u500d\u6570<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;int a,b;<br>&nbsp;cin&gt;&gt;a&gt;&gt;b;<br>&nbsp;int p=1;<br>&nbsp;for(int i=2;i&lt;=min(a,b);i++){<br>&nbsp; &nbsp; &nbsp;if(a%i==0&amp;&amp;b%i==0){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p=i;<br>&nbsp; &nbsp;  }<br>&nbsp;}<br>&nbsp;cout&lt;&lt;p; \/\/ \u6700\u5927\u516c\u7ea6\u6570<br>&nbsp;int q=a*b\/p;<br>&nbsp;cout&lt;&lt;q; \/\/ \u6700\u5c0f\u516c\u500d\u6570<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b2\uff1a\u5224\u65ad\u8d28\u6570<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;int n;<br>&nbsp;cin&gt;&gt;n;<br>&nbsp;bool f=true;<br>&nbsp;for(int i=2;i&lt;=sqrt(n);i++){<br>&nbsp; &nbsp; &nbsp;if(n%i==0){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;f=false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br>&nbsp; &nbsp;  }<br>&nbsp;}<br>&nbsp;if(f){<br>&nbsp; &nbsp; &nbsp;cout&lt;&lt;\"yes\";<br>&nbsp;}<br>&nbsp;else{<br>&nbsp; &nbsp; &nbsp;cout&lt;&lt;\"no\";<br>&nbsp;}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b3\uff1a\u6c42\u6700\u5927\u503c<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include &lt;bits\/stdc++.h&gt;<br>&nbsp;using namespace std;<br>&nbsp;int main(){<br>&nbsp; &nbsp; &nbsp;int a,b,c,d,e;<br>&nbsp; &nbsp; &nbsp;cin&gt;&gt;a&gt;&gt;b&gt;&gt;c&gt;&gt;d&gt;&gt;e;<br>&nbsp; &nbsp; &nbsp;cout&lt;&lt;max({a,b,c,d,e});<br>&nbsp; &nbsp; &nbsp;return 0;<br>&nbsp;}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b4\uff1a\u6c42a\u7684b\u6b21\u65b9<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include &lt;bits\/stdc++.h&gt;<br>&nbsp;using namespace std;<br>&nbsp;int main(){<br>&nbsp; &nbsp; &nbsp;int a,b;<br>&nbsp; &nbsp; &nbsp;cin&gt;&gt;a&gt;&gt;b;<br>&nbsp; &nbsp; &nbsp;int k=round(pow(a,b));<br>&nbsp; &nbsp; &nbsp;cout&lt;&lt;k;<br>&nbsp; &nbsp; &nbsp;return 0;<br>&nbsp;}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b5\uff1a\u9a8c\u8bc1\u5b8c\u5168\u5e73\u65b9\u6570<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp;#include &lt;bits\/stdc++.h&gt;<br>&nbsp;using namespace std;<br>&nbsp;int main(){<br>&nbsp; &nbsp; &nbsp;int n;<br>&nbsp; &nbsp; &nbsp;cin&gt;&gt;n;<br>&nbsp; &nbsp; &nbsp;int k=round(sqrt(n));<br>&nbsp; &nbsp; &nbsp;if(k*k==n){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cout&lt;&lt;\"yes\";<br>&nbsp; &nbsp;  }<br>&nbsp; &nbsp; &nbsp;else{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cout&lt;&lt;\"no\";<br>&nbsp; &nbsp;  }<br>&nbsp; &nbsp; &nbsp;return 0;<br>&nbsp;}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u6bd4\u8f83\u51fd\u6570 min(a, b) &#8211; \u8fd4\u56de\u6700\u5c0f\u503c max(a, b) &#8211; \u8fd4\u56de\u6700\u5927\u503c  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-1270","post","type-post","status-publish","format-standard","hentry","category-zl"],"_links":{"self":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/comments?post=1270"}],"version-history":[{"count":1,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1270\/revisions"}],"predecessor-version":[{"id":1271,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1270\/revisions\/1271"}],"wp:attachment":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/media?parent=1270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/categories?post=1270"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/tags?post=1270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}