{"id":93400,"date":"2024-04-15T07:06:10","date_gmt":"2024-04-14T23:06:10","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=93400"},"modified":"2024-04-15T07:06:10","modified_gmt":"2024-04-14T23:06:10","slug":"double-3","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/double-3.html","title":{"rendered":"\u8be6\u89e3C++\u4e2ddouble\u7c7b\u578b,\u5982\u4f55\u4fdd\u7559\u4e09\u4f4d\u5c0f\u6570\u70b9"},"content":{"rendered":"
\u6211\u4eec\u77e5\u9053C\u8bed\u8a00\u4e2d\uff0c\u5982\u679c\u8981\u6c42\u8f93\u51fa\u7ed3\u679c\u4fdd\u7559\u4e09\u4f4d\u5c0f\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528pritf()\u51fd\u6570\u8f7b\u677e\u7684\u89e3\u51b3\u3002\u4f46\u662fC++\u7684\u8f93\u51fa\u8fd0\u7b97\u7b26<<\u5e76\u6ca1\u6709\u76f4\u63a5\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\uff0c\u600e\u4e48\u529e\u5462\uff1f\u4e4b\u524d\u5728\u627e\u7b54\u6848\u7684\u8fc7\u7a0b\u4e2d\u5404\u8def\u5927\u795e\u7ed9\u51fa\u4e86\u5343\u59ff\u767e\u6001\u7684\u7b54\u6848\uff0c\u6211\u4e0d\u4f1a\u8fdb\u884c\u4e00\u4e00\u603b\u7ed3\uff0c\u4f46\u662f\u6211\u4eca\u5929\u4e3b\u8981\u7684\u76ee\u7684\u662f\u8bf4C++\u4e2dstd\u547d\u540d\u7a7a\u95f4\u4e2d\u76f4\u63a5\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u7684\uff01\uff01\uff01\u4e0d\u8981\u5316\u7b80\u4e3a\u7e41\uff01\uff01\uff01<\/p>\n
\u5df2\u77e5\u7ebf\u6bb5\u7684\u4e24\u4e2a\u7aef\u70b9\u5750\u6807\u662fA\uff08xa\uff0cya\uff09\uff0cB\uff08xb\uff0cyb\uff09\uff0c\u6c42\u7ebf\u6bb5AB\u7684\u957f\u5ea6\uff0c\u4fdd\u7559\u5230\u5c0f\u6570\u70b9\u540e3\u4f4d\u3002<\/p>\n
\u6837\u4f8b\u8f93\u5165\uff1a1\u00a0\u00a0\u00a0 1<\/p>\n
2\u00a0\u00a0\u00a0 2<\/p>\n
\u6837\u4f8b\u8f93\u51fa\uff1a1.414<\/p>\n
int main(int argc, char** argv) {\r\n double xa,ya,xb,yb,result;\r\n cin>> xa>>ya>>xb>>yb;\r\n result=sqrt( (xb-xa)*(xb-xa)+(yb-ya)*(yb-ya) );\r\n cout<<fixed<<setprecision(3)<<result<<endl;\r\n return 0;\r\n}<\/pre>\n\u5f88\u591a\u4eba\u4f1a\u5bf9\u4e0b\u9762\u8fd9\u53e5\u4ee3\u7801\u4e0d\u7406\u89e3\uff0c<\/p>\n
cout<<fixed<<setprecision(3)<<result<<endl;<\/pre>\n\u4e0b\u9762\u6211\u4eec\u8fdb\u884c\u91cd\u70b9\u8bb2\u89e3\uff1a<\/p>\n
\u8bbe\u7f6e\u5c0f\u6570\u70b9\u7cbe\u5ea6<\/strong><\/span><\/div>\n\u8bbe\u7f6e\u8981\u7528\u4e8e\u683c\u5f0f\u5316\u8f93\u51fa\u64cd\u4f5c\u7684\u6d6e\u70b9\u503c\u7684\u5c0f\u6570\u7cbe\u5ea6\u3002<\/p>\n
int main(int argc, char** argv) {\r\n double a=3.1415926;\r\n cout << setprecision(3) << a <<endl; \/\/3.14\r\n cout << setprecision(9) << a <<endl; \/\/3.1415926\r\n cout << fixed << setprecision(3) << a <<endl; \/\/3.142\r\n cout << fixed << setprecision(9) << a <<endl; \/\/3.141592600\r\n return 0;\r\n}<\/pre>\n\u5982\u679c\u6709\u4ec0\u4e48\u7591\u95ee\uff0c\u6b22\u8fce\u7559\u8a00\u3002\u5982\u9700\u8f6c\u8f7d\uff0c\u8bf7\u6ce8\u660e\u51fa\u5904\uff1ahttp:\/\/www.cnblogs.com\/wongyi\/p\/8204210.html<\/a><\/p>\n
\n\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.cnblogs.com\/wongyi\/p\/8204210.html<\/a><\/p>\n