{"id":47329,"date":"2024-12-02T15:16:04","date_gmt":"2024-12-02T07:16:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47329\/"},"modified":"2024-12-02T15:16:04","modified_gmt":"2024-12-02T07:16:04","slug":"%e5%87%bd%e6%95%b0%e7%9a%84%e5%8f%82%e6%95%b0%e4%bc%a0%e9%80%92%e6%96%b9%e5%bc%8f%e5%af%b9%e6%80%a7%e8%83%bd%e6%9c%89%e4%bd%95%e5%bd%b1%e5%93%8d%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47329\/","title":{"rendered":"\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300a\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002<\/p>\n<p>\u51fd\u6570\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u663e\u8457\u5f71\u54cd\u6027\u80fd\u3002\u6309\u503c\u4f20\u9012\u521b\u5efa\u53c2\u6570\u526f\u672c\uff0c\u786e\u4fdd\u539f\u59cb\u503c\u4e0d\u4f1a\u610f\u5916\u4fee\u6539\uff0c\u4f46\u590d\u5236\u5927\u578b\u6570\u636e\u7ed3\u6784\u4f1a\u964d\u4f4e\u6548\u7387\uff1b\u6309\u5f15\u7528\u4f20\u9012\u63d0\u4f9b\u5bf9\u53c2\u6570\u7684\u76f4\u63a5\u8bbf\u95ee\uff0c\u907f\u514d\u590d\u5236\uff0c\u63d0\u9ad8\u4fee\u6539\u5927\u578b\u6570\u636e\u7ed3\u6784\u7684\u6548\u7387\uff0c\u4f46\u66f4\u590d\u6742\u4e14\u53ef\u80fd\u610f\u5916\u66f4\u6539\u539f\u59cb\u503c\u3002\u9009\u62e9\u65b9\u5f0f\u53d6\u51b3\u4e8e\u573a\u666f\uff1a\u64cd\u4f5c\u5c0f\u503c\u65f6\u6309\u503c\u4f20\u9012\u66f4\u4f18\uff1b\u5904\u7406\u5927\u578b\u6570\u636e\u7ed3\u6784\u6216\u9700\u8981\u51fd\u6570\u4fee\u6539\u539f\u59cb\u503c\u65f6\uff0c\u6309\u5f15\u7528\u4f20\u9012\u66f4\u4f73\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729911201671c59a174cf6.jpg\" class=\"aligncenter\" title=\"\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f\u63d2\u56fe\" alt=\"\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f\u63d2\u56fe\" \/><\/p>\n<h2>\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f<\/h2>\n<p>\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u51fd\u6570\u7684\u6027\u80fd\u6709\u663e\u8457\u7684\u5f71\u54cd\u3002\u5728\u73b0\u4ee3\u7f16\u7a0b\u8bed\u8a00\u4e2d\uff0c\u4e3b\u8981\u6709\u4e24\u79cd\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\uff1a<\/p>\n<ul>\n<li><strong>\u6309\u503c\u4f20\u9012\uff1a<\/strong>\u5c06\u53c2\u6570\u503c\u672c\u8eab\u590d\u5236\u5230\u51fd\u6570\u5185\u90e8\u3002<\/li>\n<li><strong>\u6309\u5f15\u7528\u4f20\u9012\uff1a<\/strong>\u5c06\u6307\u5411\u53c2\u6570\u5185\u5b58\u5730\u5740\u7684\u5f15\u7528\u4f20\u9012\u5230\u51fd\u6570\u5185\u90e8\u3002<\/li>\n<\/ul>\n<p><strong>\u6309\u503c\u4f20\u9012<\/strong><\/p>\n<p>\u5728\u8fd9\u79cd\u65b9\u5f0f\u4e0b\uff0c\u51fd\u6570\u5185\u90e8\u5bf9\u53c2\u6570\u503c\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u4e0d\u4f1a\u5f71\u54cd\u8c03\u7528\u51fd\u6570\u5904\u539f\u6765\u7684\u53c2\u6570\u503c\u3002\u4f18\u70b9\uff1a<\/p>\n<ul>\n<li><strong>\u7b80\u5355\u3001\u5b89\u5168\uff1a<\/strong>\u526f\u672c\u786e\u4fdd\u4e86\u539f\u59cb\u53d8\u91cf\u4e0d\u4f1a\u88ab\u610f\u5916\u66f4\u6539\u3002<\/li>\n<li><strong>\u6548\u7387\u9ad8\uff1a<\/strong>\u590d\u5236\u5c0f\u503c\u5f00\u9500\u4f4e\u3002<\/li>\n<\/ul>\n<p>\u7f3a\u70b9\uff1a<\/p>\n<ul>\n<li><strong>\u5927\u578b\u6570\u636e\u7ed3\u6784\u4f4e\u6548\uff1a<\/strong>\u590d\u5236\u5927\u578b\u6570\u636e\u7ed3\u6784\u53ef\u80fd\u975e\u5e38\u8017\u65f6\u3002<\/li>\n<\/ul>\n<p><strong>\u6309\u5f15\u7528\u4f20\u9012<\/strong><\/p>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u63d0\u4f9b\u4e86\u5bf9\u53c2\u6570\u7684\u76f4\u63a5\u8bbf\u95ee\uff0c\u907f\u514d\u4e86\u590d\u5236\u7684\u8fc7\u7a0b\u3002\u4f18\u70b9\uff1a<\/p>\n<ul>\n<li><strong>\u5bf9\u5927\u578b\u6570\u636e\u7ed3\u6784\u9ad8\u6548\uff1a<\/strong>\u907f\u514d\u590d\u5236\u5e9e\u5927\u6570\u636e\u7ed3\u6784\u3002<\/li>\n<li><strong>\u5141\u8bb8\u53cc\u5411\u4fee\u6539\uff1a<\/strong>\u51fd\u6570\u53ef\u4ee5\u4fee\u6539\u8c03\u7528\u51fd\u6570\u5904\u539f\u6765\u7684\u53c2\u6570\u503c\u3002<\/li>\n<\/ul>\n<p>\u7f3a\u70b9\uff1a<\/p>\n<ul>\n<li><strong>\u590d\u6742\u3001\u4e0d\u5b89\u5168\uff1a<\/strong>\u51fd\u6570\u53ef\u4ee5\u610f\u5916\u66f4\u6539\u8c03\u7528\u51fd\u6570\u5904\u7684\u53c2\u6570\uff0c\u5bfc\u81f4\u610f\u5916\u540e\u679c\u3002<\/li>\n<li><strong>\u6307\u9488\u5f00\u9500\uff1a<\/strong>\u4f20\u9012\u6307\u9488\u6bd4\u4f20\u9012\u503c\u5f00\u9500\u66f4\u9ad8\u3002<\/li>\n<\/ul>\n<p><strong>\u5b9e\u6218\u6848\u4f8b\uff1a<\/strong><\/p>\n<p>\u8003\u8651\u4ee5\u4e0b\u4ea4\u6362\u4e24\u4e2a\u6570\u5b57\u7684\u51fd\u6570\uff1a<\/p>\n<pre>\/\/ \u6309\u503c\u4f20\u9012\nvoid swap_by_value(int a, int b) {\n  int temp = a;\n  a = b;\n  b = temp;\n}\n\n\/\/ \u6309\u5f15\u7528\u4f20\u9012\nvoid swap_by_reference(int &amp;x, int &amp;y) {\n  int temp = x;\n  x = y;\n  y = temp;\n}<\/pre>\n<p>\u6309\u503c\u4f20\u9012\u7684\u51fd\u6570\u9700\u8981\u590d\u5236\u4e24\u4e2a\u53d8\u91cf\uff0c\u800c\u6309\u5f15\u7528\u4f20\u9012\u7684\u51fd\u6570\u53ea\u9700\u4fee\u6539\u5185\u5b58\u5730\u5740\u3002<\/p>\n<p><strong>\u6027\u80fd\u6d4b\u8bd5\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528\u4e0d\u540c\u7684\u6570\u636e\u7c7b\u578b\uff08int\u3001\u6570\u7ec4\u3001\u5b57\u7b26\u4e32\uff09\u5bf9\u8fd9\u4e24\u4e2a\u51fd\u6570\u8fdb\u884c\u6027\u80fd\u6d4b\u8bd5\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6570\u636e\u7c7b\u578b<\/th>\n<th>\u6309\u503c\u4f20\u9012\u8017\u65f6<\/th>\n<th>\u6309\u5f15\u7528\u4f20\u9012\u8017\u65f6<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>int<\/td>\n<td>0.01 \u5fae\u79d2<\/td>\n<td>0.01 \u5fae\u79d2<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u7ec4\uff081000 \u4e2a\u5143\u7d20\uff09<\/td>\n<td>67 \u5fae\u79d2<\/td>\n<td>0.01 \u5fae\u79d2<\/td>\n<\/tr>\n<tr>\n<td>\u5b57\u7b26\u4e32\uff081000 \u4e2a\u5b57\u7b26\uff09<\/td>\n<td>200 \u5fae\u79d2<\/td>\n<td>0.02 \u5fae\u79d2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5728\u5bf9\u7b80\u5355\u6570\u636e\u7c7b\u578b\u8fdb\u884c\u64cd\u4f5c\u65f6\uff0c\u4e24\u79cd\u65b9\u5f0f\u7684\u901f\u5ea6\u5dee\u5f02\u5f88\u5c0f\u3002\u7136\u800c\uff0c\u968f\u7740\u6570\u636e\u7ed3\u6784\u7684\u589e\u5927\uff0c\u6309\u5f15\u7528\u4f20\u9012\u7684\u65b9\u5f0f\u53d8\u5f97\u66f4\u52a0\u9ad8\u6548\u3002<\/p>\n<p><strong>\u9009\u62e9\u54ea\u79cd\u4f20\u9012\u65b9\u5f0f\uff1f<\/strong><\/p>\n<p>\u9009\u62e9\u5408\u9002\u7684\u4f20\u9012\u65b9\u5f0f\u53d6\u51b3\u4e8e\u573a\u666f\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u64cd\u4f5c\u5c0f\u503c\uff0c\u5219<strong>\u6309\u503c\u4f20\u9012<\/strong>\u7b80\u5355\u3001\u5b89\u5168\u3001\u9ad8\u6548\u3002<\/li>\n<li>\u5982\u679c\u5904\u7406\u5927\u578b\u6570\u636e\u7ed3\u6784\uff0c<strong>\u6309\u5f15\u7528\u4f20\u9012<\/strong>\u53ef\u4ee5\u907f\u514d\u6602\u8d35\u7684\u590d\u5236\u64cd\u4f5c\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u51fd\u6570\u4fee\u6539\u539f\u59cb\u53c2\u6570\u503c\uff0c<strong>\u6309\u5f15\u7528\u4f20\u9012<\/strong>\u662f\u5fc5\u8981\u7684\u3002<\/li>\n<\/ul>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u6027\u80fd,\u51fd\u6570\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f \u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300a\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002 \u51fd\u6570\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u663e\u8457\u5f71\u54cd\u6027\u80fd\u3002\u6309\u503c\u4f20\u9012\u521b\u5efa\u53c2\u6570\u526f\u672c\uff0c\u786e\u4fdd\u539f\u59cb\u503c\u4e0d\u4f1a\u610f\u5916\u4fee\u6539\uff0c\u4f46\u590d\u5236\u5927\u578b\u6570\u636e\u7ed3\u6784\u4f1a\u964d\u4f4e\u6548\u7387\uff1b\u6309\u5f15\u7528\u4f20\u9012\u63d0\u4f9b\u5bf9\u53c2\u6570\u7684\u76f4\u63a5\u8bbf\u95ee\uff0c\u907f\u514d\u590d\u5236\uff0c\u63d0\u9ad8\u4fee\u6539\u5927\u578b\u6570\u636e\u7ed3\u6784\u7684\u6548\u7387\uff0c\u4f46\u66f4\u590d\u6742\u4e14\u53ef\u80fd\u610f\u5916\u66f4\u6539\u539f\u59cb\u503c\u3002\u9009\u62e9\u65b9\u5f0f\u53d6\u51b3\u4e8e\u573a\u666f\uff1a\u64cd\u4f5c\u5c0f\u503c\u65f6\u6309\u503c\u4f20\u9012\u66f4\u4f18\uff1b\u5904\u7406\u5927\u578b\u6570\u636e\u7ed3\u6784\u6216\u9700\u8981\u51fd\u6570\u4fee\u6539\u539f\u59cb\u503c\u65f6\uff0c\u6309\u5f15\u7528\u4f20\u9012\u66f4\u4f73\u3002 \u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u6027\u80fd\u6709\u4f55\u5f71\u54cd\uff1f \u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\u5bf9\u51fd\u6570\u7684\u6027\u80fd\u6709\u663e\u8457\u7684\u5f71\u54cd\u3002\u5728\u73b0\u4ee3\u7f16\u7a0b\u8bed\u8a00\u4e2d\uff0c\u4e3b\u8981\u6709\u4e24\u79cd\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\uff1a \u6309\u503c\u4f20\u9012\uff1a\u5c06\u53c2\u6570\u503c\u672c\u8eab\u590d\u5236\u5230\u51fd\u6570\u5185\u90e8\u3002 \u6309\u5f15\u7528\u4f20\u9012\uff1a\u5c06\u6307\u5411\u53c2\u6570\u5185\u5b58\u5730\u5740\u7684\u5f15\u7528\u4f20\u9012\u5230\u51fd\u6570\u5185\u90e8\u3002 \u6309\u503c\u4f20\u9012 \u5728\u8fd9\u79cd\u65b9\u5f0f\u4e0b\uff0c\u51fd\u6570\u5185\u90e8\u5bf9\u53c2\u6570\u503c\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u4e0d\u4f1a\u5f71\u54cd\u8c03\u7528\u51fd\u6570\u5904\u539f\u6765\u7684\u53c2\u6570\u503c\u3002\u4f18\u70b9\uff1a \u7b80\u5355\u3001\u5b89\u5168\uff1a\u526f\u672c\u786e\u4fdd\u4e86\u539f\u59cb\u53d8\u91cf\u4e0d\u4f1a\u88ab\u610f\u5916\u66f4\u6539\u3002 \u6548\u7387\u9ad8\uff1a\u590d\u5236\u5c0f\u503c\u5f00\u9500\u4f4e\u3002 \u7f3a\u70b9\uff1a \u5927\u578b\u6570\u636e\u7ed3\u6784\u4f4e\u6548\uff1a\u590d\u5236\u5927\u578b\u6570\u636e\u7ed3\u6784\u53ef\u80fd\u975e\u5e38\u8017\u65f6\u3002 \u6309\u5f15\u7528\u4f20\u9012 \u8fd9\u79cd\u65b9\u5f0f\u63d0\u4f9b\u4e86\u5bf9\u53c2\u6570\u7684\u76f4\u63a5\u8bbf\u95ee\uff0c\u907f\u514d\u4e86\u590d\u5236\u7684\u8fc7\u7a0b\u3002\u4f18\u70b9\uff1a \u5bf9\u5927\u578b\u6570\u636e\u7ed3\u6784\u9ad8\u6548\uff1a\u907f\u514d\u590d\u5236\u5e9e\u5927\u6570\u636e\u7ed3\u6784\u3002 \u5141\u8bb8\u53cc\u5411\u4fee\u6539\uff1a\u51fd\u6570\u53ef\u4ee5\u4fee\u6539\u8c03\u7528\u51fd\u6570\u5904\u539f\u6765\u7684\u53c2\u6570\u503c\u3002 \u7f3a\u70b9\uff1a \u590d\u6742\u3001\u4e0d\u5b89\u5168\uff1a\u51fd\u6570\u53ef\u4ee5\u610f\u5916\u66f4\u6539\u8c03\u7528\u51fd\u6570\u5904\u7684\u53c2\u6570\uff0c\u5bfc\u81f4\u610f\u5916\u540e\u679c\u3002 \u6307\u9488\u5f00\u9500\uff1a\u4f20\u9012\u6307\u9488\u6bd4\u4f20\u9012\u503c\u5f00\u9500\u66f4\u9ad8\u3002 \u5b9e\u6218\u6848\u4f8b\uff1a \u8003\u8651\u4ee5\u4e0b\u4ea4\u6362\u4e24\u4e2a\u6570\u5b57\u7684\u51fd\u6570\uff1a \/\/ \u6309\u503c\u4f20\u9012 void swap_by_value(int a, int b) { int temp = a; a = b; b = temp; } \/\/ \u6309\u5f15\u7528\u4f20\u9012 void swap_by_reference(int &amp;x, int &amp;y) { int temp = x; x [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-47329","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=47329"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47329\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}