{"id":1051,"date":"2018-03-30T18:47:27","date_gmt":"2018-03-30T10:47:27","guid":{"rendered":"https:\/\/damogame.cn:15443\/wordpress\/?p=1051"},"modified":"2018-03-30T18:47:27","modified_gmt":"2018-03-30T10:47:27","slug":"%e6%9c%89%e5%93%aa%e4%ba%9b%e9%b2%9c%e4%b8%ba%e4%ba%ba%e7%9f%a5%e5%8d%b4%e5%8f%88%e5%be%88%e5%a5%bd%e7%94%a8%e7%9a%84-stl-%e5%87%bd%e6%95%b0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/1051","title":{"rendered":"\u6709\u54ea\u4e9b\u9c9c\u4e3a\u4eba\u77e5\u5374\u53c8\u5f88\u597d\u7528\u7684 STL \u51fd\u6570\uff1f"},"content":{"rendered":"<div>\u4f5c\u8005\uff1a\u9ed8\u96e8\u86ee\u8352<br \/>\n\u94fe\u63a5\uff1ahttps:\/\/www.zhihu.com\/question\/270085840\/answer\/352317215<br \/>\n\u6765\u6e90\uff1a\u77e5\u4e4e<br \/>\n\u8457\u4f5c\u6743\u5f52\u4f5c\u8005\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u83b7\u5f97\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p>\n<div>\n<p>\u6570\u5b57\u8f6c\u5b57\u7b26\u4e32\uff1a<\/p>\n<p>string s = to_string( num);<\/p>\n<p>\u5b57\u7b26\u4e32\u8f6c\u6570\u5b57:<\/p>\n<p>int i = stoi( str);<\/p>\n<p>long l = stol( str);<\/p>\n<p>double d =stod( str);<\/p>\n<p>\u2026\u2026\u7b49<\/p>\n<p>\u540d\u79f0 \u539f\u578b \u8bf4\u660e<\/p>\n<p>stoi int stoi (const string&amp; str, size_t* idx = 0, int base = 10);<\/p>\n<p>int stoi (const wstring&amp; str, size_t* idx = 0, int base = 10); Convert string to integer (function template )<\/p>\n<p>stol long stol (const string&amp; str, size_t* idx = 0, int base = 10);<\/p>\n<p>long stol (const wstring&amp; str, size_t* idx = 0, int base = 10); Convert string to long int (function template)<\/p>\n<p>stoul unsigned long stoul (const string&amp; str, size_t* idx = 0, int base = 10);<\/p>\n<p>unsigned long stoul (const wstring&amp; str, size_t* idx = 0, int base = 10); Convert string to unsigned integer (function template)<\/p>\n<p>stoll long long stoll (const string&amp; str, size_t* idx = 0, int base = 10);<\/p>\n<p>long long stoll (const wstring&amp; str, size_t* idx = 0, int base = 10); Convert string to long long (function template)<\/p>\n<p>stoull unsigned long long stoull (const string&amp; str, size_t* idx = 0, int base = 10);<\/p>\n<p>unsigned long long stoull (const wstring&amp; str, size_t* idx = 0, int base = 10); Convert string to unsigned long long (function template)<\/p>\n<p>stof float stof (const string&amp; str, size_t* idx = 0);<\/p>\n<p>float stof (const wstring&amp; str, size_t* idx = 0); Convert string to float (function template )<\/p>\n<p>stod double stod (const string&amp; str, size_t* idx = 0);<\/p>\n<p>double stod (const wstring&amp; str, size_t* idx = 0); Convert string to double (function template )<\/p>\n<p>stold long double stold (const string&amp; str, size_t* idx = 0);<\/p>\n<p>long double stold (const wstring&amp; str, size_t* idx = 0); Convert string to long double (function template)<\/p>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<div>\n<div>\n<p>\u53ef\u80fd\u4e0d\u7b97\u9c9c\u4e3a\u4eba\u77e5\u5427\u2026\u2026\u6bd5\u7adfstl\u6ca1\u51e0\u4e2a\u2026\u2026<\/p>\n<p>inplace_merge\uff0c\u5199\u5206\u6cbb\u7684\u65f6\u5019\u5f88\u597d\u7528<\/p>\n<p>nth_element\uff0c\u5199\u66b4\u529b\u7684\u65f6\u5019\u5f88\u597d\u7528<\/p>\n<p>stable_sort\uff0csort\u7684\u65f6\u5019\u53ef\u4ee5\u5c11\u8bb0\u5f55\u4e00\u7ef4\uff0c\u867d\u7136\u7528\u4e86pair\u4e5f\u5c31\u662f\u4e24\u884c\u7684\u4e8b\u2026\u2026<\/p>\n<p>make_heap\uff0c\u5514\uff0c\u6211\u8bb0\u5f97\u8fd9\u4e2a\u4e1c\u897f\u6211\u53ea\u7528\u8fc7\u4e00\u6b21\uff1f<\/p>\n<p>S.erase(unique(S.begin(), S.end()), S.end()) \u53bb\u91cd\u5c0f\u6280\u5de7<\/p>\n<\/div>\n<p>\u4f5c\u8005\uff1a3and2and1<br \/>\n\u94fe\u63a5\uff1ahttps:\/\/www.zhihu.com\/question\/270085840\/answer\/352040460<br \/>\n\u6765\u6e90\uff1a\u77e5\u4e4e<br \/>\n\u8457\u4f5c\u6743\u5f52\u4f5c\u8005\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u83b7\u5f97\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p><\/div>\n<div><\/div>\n<div><\/div>\n<div>\n<div>\n<div>\n<p>\u53ef\u80fd\u4e0d\u7b97\u9c9c\u4e3a\u4eba\u77e5\u5427\u2026\u2026\u6bd5\u7adfstl\u6ca1\u51e0\u4e2a\u2026\u2026<\/p>\n<p>inplace_merge\uff0c\u5199\u5206\u6cbb\u7684\u65f6\u5019\u5f88\u597d\u7528<\/p>\n<p>nth_element\uff0c\u5199\u66b4\u529b\u7684\u65f6\u5019\u5f88\u597d\u7528<\/p>\n<p>stable_sort\uff0csort\u7684\u65f6\u5019\u53ef\u4ee5\u5c11\u8bb0\u5f55\u4e00\u7ef4\uff0c\u867d\u7136\u7528\u4e86pair\u4e5f\u5c31\u662f\u4e24\u884c\u7684\u4e8b\u2026\u2026<\/p>\n<p>make_heap\uff0c\u5514\uff0c\u6211\u8bb0\u5f97\u8fd9\u4e2a\u4e1c\u897f\u6211\u53ea\u7528\u8fc7\u4e00\u6b21\uff1f<\/p>\n<p>S.erase(unique(S.begin(), S.end()), S.end()) \u53bb\u91cd\u5c0f\u6280\u5de7<\/p>\n<\/div>\n<p>\u4f5c\u8005\uff1a3and2and1<br \/>\n\u94fe\u63a5\uff1ahttps:\/\/www.zhihu.com\/question\/270085840\/answer\/352040460<br \/>\n\u6765\u6e90\uff1a\u77e5\u4e4e<br \/>\n\u8457\u4f5c\u6743\u5f52\u4f5c\u8005\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u83b7\u5f97\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u9ed8\u96e8\u86ee\u8352 \u94fe\u63a5\uff1ahttps:\/\/w<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[118],"class_list":["post-1051","post","type-post","status-publish","format-standard","hentry","tag-02-"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/1051","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=1051"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/1051\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=1051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=1051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=1051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}