{"id":373,"date":"2015-03-15T15:10:46","date_gmt":"2015-03-15T07:10:46","guid":{"rendered":"http:\/\/yangwang.hk\/?p=373"},"modified":"2015-03-15T15:10:46","modified_gmt":"2015-03-15T07:10:46","slug":"2-8%e3%80%81%e4%b8%80%e4%ba%9b%e6%95%b0%e5%ad%a6%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/yangwang.hk\/?p=373","title":{"rendered":"2.8\u3001\u4e00\u4e9b\u6570\u5b66\u51fd\u6570"},"content":{"rendered":"<p>\u8fd9\u4e00\u7bc7\u672c\u6765\u51c6\u5907\u653e\u5728\u540e\u9762\u518d\u5199\u7684\uff0c\u60f3\u4e86\u534a\u5929\u8fd8\u662f\u51b3\u5b9a\u5148\u5199\u4e86<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u4e2d\u6211\u4eec\u5c06\u4ecb\u7ecd\u4e00\u7cfb\u5217\u7684\u6570\u5b66\u51fd\u6570\uff0c\u7b97\u662f\u4e3a\u540e\u9762\u6211\u4eec\u5199\u7a0b\u5e8f\u505a\u4e00\u4e9b\u51c6\u5907<\/p>\n<p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4ec5\u7ed9\u51fa\u4ee3\u7801\uff0c\u4e0d\u505a\u6f14\u793a\uff0c\u6240\u6709\u8bf7\u5927\u5bb6\u81ea\u5df1\u5bf9\u4ee3\u7801\u8fdb\u884c\u5b9e\u9a8c<span style=\"color: #ff0000;\">\uff08\u5f88\u91cd\u8981\uff09<\/span><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p>c\u8bed\u8a00\u7684\u6807\u51c6\u5e93\u4e2d\u5df2\u7ecf\u5e2e\u6211\u4eec\u5b9e\u73b0\u4e86\u8bb8\u591a\u6570\u5b66\u51fd\u6570<\/p>\n<p>\u5728\u4f7f\u7528\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u8fd9\u4e9b\u51fd\u6570\u8fdb\u884c\u201c\u58f0\u660e\u201d\uff0c\u5426\u5219\u7f16\u8bd1\u5668\u662f\u4e0d\u8ba4\u8bc6\u8fd9\u4e9b\u51fd\u6570\u7684\u3002<\/p>\n<p>\u5e93\u51fd\u6570\u7684\u58f0\u660e\u4e0d\u9700\u8981\u6211\u4eec\u81ea\u5df1\u8fdb\u884c\uff0c\u5b83\u4eec\u90fd\u5df2\u7ecf\u5199\u5165\u201c\u5934\u6587\u4ef6\u201d\u4e86\uff0c\u7528\u4e4b\u524d\u53ea\u9700\u8981\u5c06\u5b83\u201c\u5305\u542b\u201d\u8fdb\u6765<\/p>\n<p>\u5c31\u50cf\u4f7f\u7528printf\u9700\u8981include &lt;stdio.h&gt;\u4e00\u6837\uff0c\u4f7f\u7528\u6570\u5b66\u51fd\u6570\u5c31\u9700\u8981include &lt;math.h&gt;<\/p>\n<p>math\u662f\u6570\u5b66\uff0c\u8fd9\u4e2a\u4e0d\u591a\u89e3\u91ca\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u53ea\u8981\u4f7f\u7528\u5230\u4e86\u4efb\u4f55\u6807\u51c6\u5e93\u63d0\u4f9b\u7684\u6570\u5b66\u51fd\u6570\uff0c\u6211\u4eec\u5c31\u5fc5\u987b\uff08\u9664\u975e\u4f60\u624b\u5de5\u8fdb\u884c\u58f0\u660e\uff09\u5728\u7a0b\u5e8f\u5f00\u5934\u52a0\u4e0a<\/p>\n<p><strong><em>#include &lt;math.h&gt;<\/em><\/strong><\/p>\n<p>\u4e0b\u9762\u7684\u4ee3\u7801\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a\u6a21\u677f\uff0c\u4e0b\u9762\u7684\u6240\u6709\u4f8b\u5b50\u90fd\u53ef\u4ee5\u901a\u8fc7\u5c06\u6ce8\u91ca\u4fee\u6539\u4e3a\u76f8\u5173\u4ee3\u7801\u800c\u6267\u884c<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;math.h&gt;\r\n\r\nint main()\r\n{\r\n    int int_a = -2;\r\n    double double_a = -2.0;\r\n\r\n    \/\/add your code here \u5728\u6b64\u5904\u6dfb\u52a0\u4ee3\u7801\r\n    return 0;\r\n}\r\n<\/pre>\n<hr \/>\n<p>&nbsp;<\/p>\n<h3>abs()<\/h3>\n<p>\u6211\u4eec\u5148\u4ece\u7edd\u5bf9\u503c\u51fd\u6570\u5f00\u59cb,\u82e5\u60f3\u6c42\u4e00\u4e2a\u6570\u7684\u7edd\u5bf9\u503c\uff0c\u53ea\u9700\u8981abs\u5c31\u884c\u4e86\uff0c\u5982<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nint_a = abs(int_a);\r\nprintf(&quot;%d\\n&quot;, int_a);\r\n<\/pre>\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0cabs\u51fd\u6570\u53ea\u652f\u6301int\u578b\u7684\u6570\u636e\uff0c\u5982\u679c\u8981\u6c42\u4e00\u4e2adouble\u503c\u7684\u7edd\u5bf9\u503c\u5462\uff1f<\/p>\n<p>\u90a3\u5c31\u9700\u8981\u201c\u5347\u7ea7\u7248\u201d\uff1a<em><strong>fabs()<\/strong><\/em><\/p>\n<p>\u7528\u6cd5\u5b8c\u5168\u76f8\u540c\uff0c\u4f46\u662f\u53c2\u6570\u5374\u662fdouble\u578b\u7684\uff08\u5982\u679c\u4f60\u7ed9\u7684\u662ffloat\u7c7b\u578b\u7684\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5e2e\u4f60\u8f6c\u6362\uff09<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\ndouble_a = fabs(double_a);\r\nprintf(&quot;%f\\n&quot;, double_a);\r\n<\/pre>\n<h3>sqrt()<\/h3>\n<p>\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u8ba1\u7b97\u5e73\u65b9\u6839\uff0c\u8fd9\u6837\u8fd9\u4e2a\u51fd\u6570\u5c31\u6d3e\u4e0a\u7528\u573a\u4e86<\/p>\n<p><em><strong>sqrt()<\/strong><\/em>\u5c06\u63a5\u53d7\u4e00\u4e2adouble\u7c7b\u578b\u7684\u53c2\u6570\uff0c\u8ba9\u540e\u5b83\u5c06\u8fd4\u56de\u7ed9\u4f60\u5e73\u65b9\u6839<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n    double_a = fabs(double_a);\r\n    double_a = sqrt(double_a);\r\n    printf(&quot;%f\\n&quot;, double_a);\r\n<\/pre>\n<p>\u4f46\u662f\u6211\u4eec\u4e00\u822c\u559c\u6b22\u8fd9\u6837\u5199<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n    double_a = sqrt(fabs(double_a));\r\n    printf(&quot;%f\\n&quot;, double_a);\r\n<\/pre>\n<p>\u751a\u81f3\u662f<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n    printf(&quot;%f\\n&quot;, sqrt(fabs(double_a)));\r\n<\/pre>\n<h3>pow()<\/h3>\n<p>\u5728\u8ba1\u7b97\u4e00\u4e2a\u6570\u7684\u5e42\u65f6\uff0c\u5c31\u9700\u8981\u7528\u5230<em><strong>pow()<\/strong><\/em>\u4e86<\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u6709\u4e24\u4e2a\u53c2\u6570<strong>pow(double x, double y);<\/strong>\uff0c\u53c2\u6570x\u548cy\u90fd\u662fdouble\u7c7b\u578b\u7684<\/p>\n<p>\u51fd\u6570\u8fd4\u56de\u7684\u503c\u662fx\u7684y\u6b21\u5e42<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n    printf(&quot;%g\\n&quot;, pow(2, 10));\r\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5e8f\u8fd0\u884c\u5c06\u663e\u793a1024\uff0c\u8fd9\u662f2\u768410\u6b21\u65b9\u7684\u503c<\/p>\n<p>\u5207\u8bb0\uff0c\u8fd9\u4e2a\u51fd\u6570\u8fd4\u56de\u7684\u503c\u662fdouble\u7c7b\u578b\uff0c\u56e0\u6b64\u8f93\u51fa\u9700\u8981\u4f7f\u7528%f\u6216\u8005%g\uff01\uff08\u5f53\u7136\uff0c\u4e5f\u9700\u8981\u4e00\u4e2adouble\u7c7b\u578b\u53d8\u91cf\u53bb\u63a5\u6536\u5b83\uff09<\/p>\n<p>\u5982\u679c\u4f60\u89c9\u5f97pow\u51fd\u6570\u4ec5\u4ec5\u5982\u6b64\u90a3\u5c31\u5927\u9519\u7279\u9519\u4e86\uff0c\u65e2\u7136\u5b83\u7684\u53c2\u6570\u90fd\u662fdouble\u7c7b\u578b\uff0c\u8bf4\u660e\u8fd9\u4e2a\u51fd\u6570\u80af\u5b9a\u80fd\u8ba1\u7b97\u975e\u6574\u6570\u5e42\uff01\u6211\u4eec\u6765\u8bd5\u4e00\u4e0b<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n    printf(&quot;%g\\n&quot;, pow(2, 1.5));\r\n<\/pre>\n<p>\u8fd9\u6837\u4e00\u6765\uff0cpow\u51fd\u6570\u5c31\u5f88\u6709\u7528\u4e86\u3002\u4e0a\u9762\u7684sqrt\u51fd\u6570\u53ea\u80fd\u8ba1\u7b97\u5e73\u65b9\u6839\uff0c\u7acb\u65b9\u6839\u600e\u4e48\u529e\uff1f<\/p>\n<p>\u6c42\u5b83\u7684\u4e09\u5206\u4e4b\u4e00\u6b21\u5e42\u4e0d\u5c31\u597d\u4e86<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n    printf(&quot;%g\\n&quot;, pow(8, 0.3333333333));\r\n<\/pre>\n<p>8\u7684\u7acb\u65b9\u6839\u662f2\uff0c\u8fd9\u5e94\u8be5\u662f\u6b64\u7a0b\u5e8f\u7684\u7ed3\u679c<\/p>\n<h3>log(), log10()<\/h3>\n<p>\u8fd9\u4e24\u4e2a\u4e00\u770b\u5c31\u77e5\u9053\u662f\u6c42\u5bf9\u6570\u7684\u4e86<\/p>\n<p><strong>log10()<\/strong>\u662f\u6c42\u4ee510\u4e3a\u5e95\u7684\u5bf9\u6570\uff0c<strong>log()<\/strong>\u5219\u662f\u4ee5e\u4e3a\u5e95<\/p>\n<p>\u7528\u6cd5\u548c\u524d\u9762\u7684sqrt()\u7c7b\u4f3c\uff0c\u8bf7\u81ea\u5df1\u5199\u51fa\u4ee3\u7801<\/p>\n<p>\u5982\u679c\u4f60\u8981\u95ee\u5982\u679c\u6211\u8981\u7b97\u522b\u7684\u5e95\u7684\u5bf9\u6570\u600e\u4e48\u529e\uff1f<\/p>\n<p>\u8fd8\u80fd\u600e\u4e48\u529e\uff0c\u6362\u5e95\u516c\u5f0f\u5457\uff01<\/p>\n<h3>\u4e09\u89d2\u51fd\u6570<\/h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u8fd9\u4e9b\u51fd\u6570\u7528\u7684\u4e0d\u50cf\u4e0a\u9762\u7684\u90a3\u4e48\u591a<\/p>\n<p><strong>sin(), cos(), tan()<\/strong><\/p>\n<p>\u4ee5\u53ca\u53cd\u4e09\u89d2\u51fd\u6570<strong>asin()\uff0cacos()\uff0catan()<\/strong><\/p>\n<p>\u7528\u6cd5\u548csqrt\u7c7b\u4f3c\uff0c\u540c\u6837\u4e0d\u7ed9\u51fa\u4ee3\u7801\uff01<\/p>\n<p>\u6807\u51c6\u5e93\u7684\u6570\u5b66\u51fd\u6570\u8fd8\u6709\u51e0\u4e2a\uff0c\u518d\u5f80\u4e0b\u5199\u6211\u4f30\u8ba1\u4f60\u5c31\u60f3\u53f3\u4e0a\u89d2\u5355\u51fb\u4e86\u2026\u2026<\/p>\n<p>\u6240\u4ee5\u540e\u9762\u7528\u5f97\u4e0a\u7684\u5730\u65b9\u518d\u8bf4\u5427<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e00\u7bc7\u672c\u6765\u51c6\u5907\u653e\u5728\u540e\u9762\u518d\u5199\u7684\uff0c\u60f3\u4e86\u534a\u5929\u8fd8\u662f\u51b3\u5b9a\u5148\u5199\u4e86 \u8fd9\u7bc7\u6587\u7ae0\u4e2d\u6211\u4eec\u5c06\u4ecb\u7ecd\u4e00\u7cfb\u5217\u7684\u6570\u5b66\u51fd\u6570\uff0c\u7b97\u662f\u4e3a\u540e\u9762\u6211\u4eec\u5199\u7a0b\u2026 <span class=\"read-more\"><a href=\"https:\/\/yangwang.hk\/?p=373\">Read More: 2.8\u3001\u4e00\u4e9b\u6570\u5b66\u51fd\u6570 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-373","post","type-post","status-publish","format-standard","hentry","category-c"],"views":2295,"_links":{"self":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=373"}],"version-history":[{"count":4,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/373\/revisions"}],"predecessor-version":[{"id":383,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/373\/revisions\/383"}],"wp:attachment":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}