{"id":677,"date":"2023-12-01T09:01:01","date_gmt":"2023-12-01T01:01:01","guid":{"rendered":""},"modified":"2023-12-01T09:01:01","modified_gmt":"2023-12-01T01:01:01","slug":"CPU\u773c\u91cc\u7684\uff1a\u6570\u7ec4","status":"publish","type":"post","link":"https:\/\/mushiming.com\/677.html","title":{"rendered":"CPU\u773c\u91cc\u7684\uff1a\u6570\u7ec4"},"content":{"rendered":"
\u201c<\/span><\/strong>\u5343\u4e07\u4e0d\u8981\u88ab\u6570\u7ec4\u7b80\u5355\u7684\u5916\u8868\u8ff7\u60d1\uff0c\u5b83\u7684\u4e8b\uff0c\u6bd4\u4f60\u60f3\u8c61\u7684\u591a<\/span>\u201d<\/span><\/strong><\/p>\n <\/p>\n 01<\/span><\/p>\n \u63d0\u51fa\u95ee\u9898<\/span><\/p>\n \u6570\u7ec4\u53ef\u80fd\u662f\u6700\u5177\u6b3a\u9a97\u6027\u7684\u6570\u636e\u7c7b\u578b\u3002\u4ec5\u4ece\u8bed\u6cd5\u5b9a\u4e49\u4e0a\u770b\uff0c\u5b83\u975e\u5e38\u7b80\u5355\uff1b\u4f3c\u4e4e\u7528\u6cd5\u8ddf\u666e\u901a\u53d8\u91cf\u76f8\u540c\uff0c\u4ec5\u4ec5\u53ea\u6709\u6570\u91cf\u4e0a\u7684\u5dee\u5f02\u3002\u4f46\u771f\u6b63\u4f7f\u7528\u6570\u7ec4\u7684\u65f6\u5019\uff0c\u5374\u5b8c\u5168\u662f\u4e24\u56de\u4e8b<\/span><\/p>\n <\/p>\n 02<\/span><\/p>\n \u4e00\u7ef4\u6570\u7ec4<\/span><\/span><\/p>\n \u8ba9\u6211\u4eec\u5148\u4ece\u6700\u7b80\u5355\u7684\u5f00\u59cb\uff0c\u6253\u5f00Compiler Explorer\uff0c\u5199\u4e00\u4e2a\u6700\u7b80\u5355\u7684\u5bf9\u6570\u7ec4\u8d4b\u503c\u7684\u51fd\u6570\uff1a<\/span><\/span><\/p>\n \u901a\u8fc7\u5bf9\u5e94\u7684\u6c47\u7f16\u6307\u4ee4\uff0c\u53ef\u4ee5\u5f88\u5bb9\u6613\u731c\u5230\uff1a\u8fd9\u4e2a\u8d4b\u503c\u8fc7\u7a0b\uff0c\u5c31\u662f\u5728\u5bf9\u4e00\u6bb5\u8fde\u7eed\u7684\u5185\u5b58\u8d4b\u503c\u3002\u56e0\u4e3a int \u7c7b\u578b\u662f 4 \u5b57\u8282\u957f\u5ea6\uff0c\u6240\u4ee5\uff0c\u6bcf\u4e2a\u5143\u7d20\u7684\u5730\u5740\u95f4\u9694\u90fd\u662f 4 \u4e2a\u5b57\u8282\u3002<\/span><\/p>\n \u540c\u7406\uff0c\u5982\u679c\u662f char \u7c7b\u578b\u7684\u6570\u7ec4\uff0c\u6bcf\u4e2a\u5143\u7d20\u7684\u5730\u5740\u95f4\u9694\u5c31\u662f 1 \u4e2a\u5b57\u8282\u3002<\/span><\/p>\n \u6240\u4ee5\uff0c\u6211\u4eec\u53ef\u4ee5\u8111\u8865\u4e00\u4e0b\u6570\u7ec4 a \u5728\u5185\u5b58\u4e2d\u7684\u6837\u5b50\uff0c\u5927\u6982\u5c31\u662f\u957f\u8fd9\u4e2a\u6837\u5b50\uff1a<\/span><\/p>\n \u770b\u5230\u8fd9\u79cd\u8fde\u7eed\u7684\u5185\u5b58\uff0c\u4f60\u4f1a\u60f3\u5230\u4ec0\u4e48\uff1f\u662f\u7684\uff0c\u53c8\u662f\u6307\u9488\u3002\u56e0\u4e3a\uff0c\u53ea\u8981\u77e5\u9053\u6570\u7ec4 a \u7684\u9996\u5730\u5740\u548c\u957f\u5ea6\uff1b\u4e00\u6837\u53ef\u4ee5\u51c6\u786e\u7684\u5b9a\u4f4d\uff1a\u6570\u7ec4 a \u6240\u5728\u7684\u5185\u5b58\u7a7a\u95f4\u3002<\/span><\/p>\n \u4e0d\u8981\u4ee5\u4e3a\uff0c\u8fd9\u662f\u963f\u5e03\u7684\u4e00\u53a2\u60c5\u613f\u3002\u5b9e\u9645\u4e0a\uff0c\u5f88\u591a\u7f16\u8bd1\u5668\u5c31\u662f\u8fd9\u4e48\u5e72\u7684\uff01\u8ba9\u6211\u4eec\u5199\u4e00\u4e2a\u6700\u7b80\u5355\u7684\u7528\u6570\u7ec4\u53d8\u91cf\u4f5c\u53c2\u6570\u7684\u51fd\u6570\uff1b\u518d\u5199\u4e00\u4e2a\u6700\u7b80\u5355\u7684\u7528\u6307\u9488\u53d8\u91cf\u4f5c\u53c2\u6570\u7684\u51fd\u6570\uff1a<\/span><\/p>\n \u6ca1\u60f3\u5230\u5427\uff1f\u5b83\u4eec\u7684\u6c47\u7f16\u6307\u4ee4\u7adf\u7136\u662f\u4e00\u6a21\u4e00\u6837\u7684\uff01<\/span><\/p>\n \u6240\u4ee5\uff0c\u5728\u4f20\u9012\u6570\u7ec4\u53c2\u6570\u7684\u65f6\u5019\uff0c\u65e0\u8bba\u4f60\u7684\u6570\u7ec4\u6709\u591a\u5927\uff0c\u7f16\u8bd1\u5668\u90fd\u4e0d\u4f1a\u50cf\u666e\u901a\u53d8\u91cf\u90a3\u6837\uff0c\u4e3a\u4f60\u5728\u201c\u5806\u6808\u201d\u4e2d\uff0c\u6784\u5efa\u4e00\u4e2a\u76f8\u540c\u5927\u5c0f\u7684\u4e34\u65f6\u6570\u7ec4\u53d8\u91cf\u3002<\/span><\/p>\n \u800c\u662f\uff0c\u7b80\u7b80\u5355\u5355\u7684\u4f20\u9012\u4e00\u4e2a\u6570\u7ec4\u7684\u5185\u5b58\u9996\u5730\u5740\uff0c\u50cf\u4f20\u9012\u6307\u9488\u53d8\u91cf\u4e00\u6837\uff0c\u628a\u6570\u7ec4\u7684\u5185\u5b58\u9996\u5730\u5740\uff0c\u4f20\u9012\u7ed9\uff1a\u88ab\u8c03\u51fd\u6570\u3002\u800c\u5bf9\u6570\u7ec4\u7684\u8bfb\u3001\u5199\u64cd\u4f5c\uff0c\u5219\u7b49\u4ef7\u4e8e\u5bf9\u6307\u9488\u7684 * \u64cd\u4f5c\u3002<\/span><\/p>\n \u518d\u5199\u4e00\u4e2a\u51fd\u6570\uff0c\u4f5c\u4e00\u4e0b\u8c03\u7528\uff1a<\/span><\/p>\n \u5982\u4f60\u6240\u89c1\uff0c\u8fd9 3 \u79cd\u8c03\u7528\u5f62\u5f0f\uff0c\u5bf9\u5e94\u7684CPU\u6307\u4ee4\u5b8c\u5168\u4e00\u81f4\uff01\u5b83\u4eec\u672c\u8d28\u4e0a\u5b8c\u5168\u76f8\u540c\uff0c\u90fd\u662f\u5728\u4f20\u9012\u6570\u7ec4\u7684\u5185\u5b58\u9996\u5730\u5740\uff0c\u800c\u975e\u6784\u5efa\u4e34\u65f6\u6570\u7ec4\u3002<\/span><\/p>\n \u6211\u4eec\u9700\u8981\u4e60\u60ef\u8fd9\u79cd\u4f20\u9012\u6307\u9488\u7684\u5f62\u5f0f\uff0c\u5f88\u591a\u77e5\u540d\u7684\u5f00\u6e90\u8f6f\u4ef6\uff08\u64cd\u4f5c\u7cfb\u7edf\u3001\u534f\u8bae\u6808\uff09\u4e5f\u662f\u8fd9\u4e48\u4f5c\u7684\u3002\u5f53\u7136\uff0c\u4e3a\u4e86\u9632\u6b62\u8d8a\u754c\uff0c\u8fd8\u4f1a\u589e\u52a0\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u6570\u7ec4\u7684\u957f\u5ea6\uff1a<\/span><\/p>\n <\/p>\n 03<\/span><\/p>\n \u591a\u7ef4\u6570\u7ec4<\/p>\n \u6700\u540e\u662f \u4e8c\u7ef4\u3001\u4e09\u7ef4 \u6570\u7ec4\uff0c\u53ef\u80fd\u4f60\u5fc3\u4e2d\u7684\uff1a\u4e00\u7ef4\u3001\u4e8c\u7ef4\u3001\u4e09\u7ef4\u6570\u7ec4\u957f\u8fd9\u4e2a\u6837\u5b50\uff1a<\/p>\n \u4f46\u5f88\u9057\u61be\uff0c\u8ba1\u7b97\u673a\u7684\u5185\u5b58\u6761\u662f\u4e00\u7ef4\u7684\uff0c\u5728CPU\u773c\u91cc\uff0c\u591a\u7ef4\u6570\u7ec4\uff0c\u90fd\u662f\u5728\u5f53\u4e00\u7ef4\u6570\u7ec4\u6765\u5904\u7406\u3002\u4e8b\u5b9e\u80dc\u4e8e\u96c4\u8fa9\uff0c\u4e0b\u97623\u4e2a\u51fd\u6570\uff0c\u5206\u522b\u5728\u7ed9\u4e00\u7ef4\u3001\u4e8c\u7ef4\u3001\u4e09\u7ef4\u6570\u7ec4\u8d4b\u503c\uff1a<\/p>\n \u4f46\u663e\u7136\uff0c\u5b83\u4eec\u7684\u6c47\u7f16\u6307\u4ee4\uff0c\u5b8c\u5168\u76f8\u540c\uff01\u6240\u4ee5\uff0c\u65e0\u8bba\u6570\u7ec4\u662f\u4e00\u7ef4\u7684\u8fd8\u662f\u9ad8\u7ef4\u7684\uff0c\u5b83\u90fd\u662f\u4e00\u6bb5\u8fde\u7eed\u7684\u4e00\u7ef4\u5185\u5b58\u3002<\/p>\n <\/p>\n 04<\/span><\/p>\n \u603b\u7ed3<\/p>\n <\/p>\n 05<\/span><\/p>\n \u70ed\u70b9\u95ee\u9898<\/p>\n Q1\uff1a\u4e3a\u4ec0\u4e48\u7ecf\u5e38\u770b\u89c1\u628a\u6307\u9488\uff0c\u5f53\u6570\u7ec4\u4e00\u6837\u4f7f\u7528\u5462\uff1f\u53ef\u4ee5\u8ba4\u4e3a\u6307\u9488\u548c\u6570\u7ec4\u662f\u7b49\u4ef7\u7684\u5417\uff1f<\/p>\n A1\uff1a\u8fd9\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u95ee\u9898\uff01\u5728\u7f16\u7a0b\u5b9e\u8df5\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u770b\u89c1\u628a\u6307\u9488\u5f53\u4f5c\u6570\u7ec4\u4f7f\u7528\u7684\u60c5\u51b5\u3002\u4f46\u53ef\u4ee5\u786e\u5b9a\u7684\u662f\u6307\u9488\u548c\u6570\u7ec4\u662f\u4e0d\u7b49\u4ef7\u7684\u3002<\/p>\n \u6307\u9488\u53d8\u91cf\u53ea\u662f\u8bb0\u5f55\u4e86\u4e00\u4e2a\u5185\u5b58\u5730\u5740\u3002\u5982\u679c\u662f32\u4f4d\u7684CPU\uff0c\u8fd9\u4e2a\u5185\u5b58\u5730\u5740\u4f1a\u5360\u636e4\u5b57\u8282\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5982\u679c\u662f64\u4f4d\u7684CPU\uff0c\u8fd9\u4e2a\u5185\u5b58\u5730\u5740\u5219\u5360\u75288\u5b57\u8282\u7684\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n \u800c\u6570\u7ec4\u53ef\u80fd\u662f\u591a\u7ec4\u6570\u636e\uff0c\u5176\u5360\u7528\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5f80\u5f80\u4e0d\u6b624\u62168\u4e2a\u5b57\u8282\u3002\u867d\u7136\u6307\u9488\u7ecf\u5e38\u53d8\u5f62\u6210\u6570\u7ec4\u4f7f\u7528\uff0c\u4f46\u5b83\u7684\u771f\u5b9e\u610f\u56fe\uff0c\u8fd8\u662f\u5728\u4f5c\u5730\u5740\u504f\u79fb\u3002\u4f8b\u5982\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/span><\/p>\n \u901a\u8fc7Compiler Explorer\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff1a\u51fd\u6570func1\u548c\u51fd\u6570func2\u5bf9\u5e94\u7684CPU\u6307\u4ee4\u662f\u5b8c\u5168\u4e00\u81f4\u7684\u3002\u6240\u4ee5p[1]\u5b9e\u8d28\u4e0a\u662f\u5728\u4f5c\u4e00\u4e2a\u5b57\u8282\u7684\u5185\u5b58\u5730\u5740\u504f\u79fb\uff1a(p + 1)\uff0c\u7136\u540e\u518d\u5bf9\u65b0\u5730\u5740\uff0c\u505a\u8bfb\u64cd\u4f5c\uff1a*(p + 1)\u3002<\/p>\n \u867d\u7136p[1]\u7684\u5199\u6cd5\u66f4\u52a0\u7b80\u6d01\uff0c\u4f46\u540c\u6837\u8bef\u5bfc\u6027\u4e5f\u6bd4\u8f83\u5f3a\uff0c\u4f1a\u8ba9\u5f00\u53d1\u8005\u8bef\u4ee5\u4e3ap\u662f\u4e00\u4e2a\u6570\u7ec4\u3002\u5f53\u7136\uff0c\u4e0d\u4ec5\u4e00\u7ef4\u6570\u7ec4\u5982\u6b64\uff0c\u4e8c\u7ef4\u6570\u7ec4\u4e5f\u5b58\u5728\u7c7b\u4f3c\u7684\u95ee\u9898\uff0c\u6211\u4eec\u672a\u6765\u4e5f\u4f1a\u770b\u5230\u7c7b\u4f3c\u7684\u6848\u4f8b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"CPU\u773c\u91cc\u7684\uff1a\u6570\u7ec4\u201c\u5343\u4e07\u4e0d\u8981\u88ab\u6570\u7ec4\u7b80\u5355\u7684\u5916\u8868\u8ff7\u60d1\uff0c\u5b83\u7684\u4e8b\uff0c\u6bd4\u4f60\u60f3\u8c61\u7684\u591a\u201d01\u63d0\u51fa\u95ee\u9898\u6570\u7ec4\u53ef\u80fd\u662f\u6700\u5177\u6b3a\u9a97\u6027\u7684\u6570\u636e\u7c7b\u578b\u3002\u4ec5\u4ece\u8bed\u6cd5...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/677"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=677"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/677\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}void func(int* array, int length)<\/code><\/pre>\n
\n