{"id":297167,"date":"2020-01-15T15:00:14","date_gmt":"2020-01-15T15:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=297167"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=297167","title":{"rendered":"\u041d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 C\/C++"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/484082\/\">\u042d\u0442\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 (<a href=\"https:\/\/habr.com\/ru\/post\/483864\/\">\u043f\u0435\u0440\u0432\u044b\u0439<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/484002\/\">\u0432\u0442\u043e\u0440\u043e\u0439<\/a>). \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0430 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435, \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0435\u0439 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0417\u0430\u0434\u0430\u0447\u0443 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0437 \u043d\u0430\u0448\u0443\u043c\u0435\u0432\u0448\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/478878\/\">\u00ab\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0447\u0438\u0441\u043b\u0430 (\u0431\u0430\u0439\u0442\u043e\u0432) \u0432 \u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0443 \u0421\u0418\u00bb<\/a>, \u043e\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439, \u0432 \u0441\u0438\u043b\u0443 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f, <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9E%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F_(%D0%BC%D0%B0%D1%82%D0%B5%D0%BC%D0%B0%D1%82%D0%B8%D0%BA%D0%B0)\">\u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/a> \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0437\u0430\u0434\u043e\u043b\u0433\u043e \u0434\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0439 \u044d\u043f\u043e\u0445\u0438, \u0430\u043a\u0441\u0438\u043e\u043c\u0430 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445 (\u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b) \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c: \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u044d\u0442\u043e \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430, \u043d\u043e \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430\u043c. \u0411\u0440\u0430\u0439\u0430\u043d \u0423. \u041a\u0435\u0440\u043d\u0438\u0433\u0430\u043d \u0438 \u0420\u043e\u0431 \u041f\u0430\u0439\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u043d\u0438\u0433\u0443 <a href=\"https:\/\/www.ozon.ru\/context\/detail\/id\/1927500\/\">\u00ab\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\/The Practice of Programming\u00bb<\/a> 1999 \u0433\u043e\u0434. \u0412 \u0433\u043b\u0430\u0432\u0435 3 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u043b\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435, \u043d\u0430 \u044f\u0437\u044b\u043a\u0430\u0445 \u201cC\u201d \u201cC++\u201d \u201cJava\u201d \u201cAwk\u201d \u201cPerl\u201d, \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430:<\/p>\n<pre><code class=\"python\">+-----------------+---------------+--------------------+-----------------------+ |                 | 250\u041c\u0413\u0446,R10000 | 400 \u041c\u0413\u0446,Pentium II | \u0421\u0442\u0440\u043e\u043a \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 | +-----------------+---------------+--------------------+-----------------------+ | C               | 0,36\u0441         | 0,30\u0441              | 150                   | | Java            | 4,6           | 9,2                | 105                   | | C++\/STL\/\u043e\u0447\u0435\u0440\u0435\u0434\u044c | 2,6           | 11,2               | 70                    | | C++\/STL\/\u0441\u043f\u0438\u0441\u043e\u043a  | 1,7           | 1,5                | 70                    | | Awk             | 2,2           | 2,1                | 20                    | | Perl            | 1,8           | 1,0                | 18                    | +-----------------+---------------+--------------------+-----------------------+<\/code><\/pre>\n<p>  \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0432\u0441\u0435 \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e, \u043d\u043e \u0435\u0441\u043b\u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043d\u0438\u0433\u0443 \u0430 \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0442\u043e \u0432\u044b\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C, \u0431\u044b\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0445\u044d\u0448 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a, \u0430 \u043d\u0430 C++ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u043c\u0435\u0441\u0442\u043e \u0445\u044d\u0448, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0438\u0445 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u0430 \u0445\u044d\u0448\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u0434\u0435\u0442 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0441 \u0445\u044d\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c\u0438, \u0445\u043e\u0440\u043e\u0448\u043e \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/483864\/#comment_21131942\">\u00ab\u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e\u00bb<\/a> \u043a\u043e\u0434\u0430, \u043d\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0435\u0442 \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u043d\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/post\/484002\/#comment_21134354\">\u043f\u043e\u0434\u043b\u043e\u0433<\/a> \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u043e\u0432 Awk \u0438 Perl \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0437\u0430 \u0441\u0447\u0435\u0442 \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u043c\u0430\u043b\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0438 \u0441\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.cs.princeton.edu\/~bwk\/tpop.webpage\/code.html\">\u043a\u043e\u0434 \u0438\u0437 \u043a\u043d\u0438\u0433\u0438<\/a>, \u043e\u043d \u0435\u0441\u0442\u044c \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043f\u043e <a href=\"https:\/\/www.cs.princeton.edu\/~bwk\/tpop.webpage\/code.html\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0440 \u0438 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0434 \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0436\u0435\u043b\u0435\u0437\u0435 \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u043b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u043d\u043e \u0441\u0442\u043e\u0438\u043b\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 C++ \u043d\u0430 \u0445\u044d\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c C \u0438 C++ \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0430 Awk \u0438\u043b\u0438 Perl, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430 \u043c\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043a\u043e\u0434 C++ \u0432 3 \u0440\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 C.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">C++ like perl + \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;unordered_map&gt; #include &lt;vector&gt; std::vector&lt;std::string_view&gt; splitSV(std::string_view str, std::string_view delims = \" \\t\\n\\r\") {     std::vector&lt;std::string_view&gt; output;     output.reserve(str.size() \/ 2);     for (auto first = str.data(), second = str.data(), last = first + str.size(); second != last &amp;&amp; first != last; first = second + 1) {         second = std::find_first_of(first, last, std::cbegin(delims), std::cend(delims));         if (first != second)             output.emplace_back(first, second - first);     }     return output; }  int main(void) {     srand(time(nullptr));      std::string NONWORD = \"\\n\";     std::string_view w1 = NONWORD;     std::string_view w2 = NONWORD;     std::unordered_map&lt;std::string, std::vector&lt;std::string_view&gt;&gt; statetab;     statetab.reserve(15000);      std::ifstream file(\"c:\\\\!\\\\psalms.txt\");     std::vector&lt;char&gt; data(std::istreambuf_iterator&lt;char&gt;(file), {});     auto book = splitSV(std::string_view(data.data(), data.size()));      std::string t;     t.reserve(1000);     for (auto &amp;w3 : book) {         t.clear();         t += w1;         t += w2;         statetab[t].emplace_back(w3);         w2 = w3;         w1 = w2;     }      w1 = w2 = NONWORD;     for (int i = 0; i &lt; 10000; i++) {         t.clear();         t += w1;         t += w2;         auto &amp;vec = statetab[t];         w2 = vec[rand() % vec.size()];         w1 = w2;         \/\/std::cout &lt;&lt; w2 &lt;&lt; \"\\n\";     }     return 0; }<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0430 \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0447\u0438\u0441\u043b\u0430 (\u0431\u0430\u0439\u0442\u043e\u0432) \u0432 \u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0443 \u0421\u0418<\/h2>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Java 10-\u043e\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">\/\/ From: https:\/\/programming.guide\/the-worlds-most-copied-so-snippet.html public static strictfp String humanReadableByteCount(long bytes, boolean si) {     int unit = si ? 1000 : 1024;     long absBytes = bytes == Long.MIN_VALUE ? Long.MAX_VALUE : Math.abs(bytes);     if (absBytes &lt; unit) return bytes + \" B\";     int exp = (int) (Math.log(absBytes) \/ Math.log(unit));     long th = (long) (Math.pow(unit, exp) * (unit - 0.05));     if (exp &lt; 6 &amp;&amp; absBytes &gt;= th - ((th &amp; 0xfff) == 0xd00 ? 52 : 0)) exp++;     String pre = (si ? \"kMGTPE\" : \"KMGTPE\").charAt(exp - 1) + (si ? \"\" : \"i\");     if (exp &gt; 4) {         bytes \/= unit;         exp -= 1;     }     return String.format(\"%.1f %sB\", bytes \/ Math.pow(unit, exp), pre); }<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Java 2-\u043e\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">public static String humanReadableByteCountBin(long bytes) {     long b = bytes == Long.MIN_VALUE ? Long.MAX_VALUE : Math.abs(bytes);     return b &lt; 1024L ? bytes + \" B\"             : b &lt;= 0xfffccccccccccccL &gt;&gt; 40 ? String.format(\"%.1f KiB\", bytes \/ 0x1p10)             : b &lt;= 0xfffccccccccccccL &gt;&gt; 30 ? String.format(\"%.1f MiB\", bytes \/ 0x1p20)             : b &lt;= 0xfffccccccccccccL &gt;&gt; 20 ? String.format(\"%.1f GiB\", bytes \/ 0x1p30)             : b &lt;= 0xfffccccccccccccL &gt;&gt; 10 ? String.format(\"%.1f TiB\", bytes \/ 0x1p40)             : b &lt;= 0xfffccccccccccccL ? String.format(\"%.1f PiB\", (bytes &gt;&gt; 10) \/ 0x1p40)             : String.format(\"%.1f EiB\", (bytes &gt;&gt; 20) \/ 0x1p40); }<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0437 \u043f\u043e\u0441\u0442\u0430 \u0434\u0432\u0430 \u043a\u043e\u0434\u0430: \u043e\u0434\u0438\u043d \u043e\u0431\u0449\u0438\u0439 \u0434\u043b\u044f 10-\u043e\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u043b\u044f 2-\u043e\u0433\u043e. \u0421\u0440\u0430\u0437\u0443 \u0445\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u043e\u0434 \u0434\u043b\u044f 10-\u043e\u0433\u043e \u0431\u044b\u043b \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0439, \u0442\u043e \u043a\u043e\u0434 \u0434\u043b\u044f 2-\u043e\u0433\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432\u0441\u0435 \u0447\u0438\u0441\u043b\u0430 \u043e\u043a\u0440\u0443\u0433\u043b\u044f\u0442\u0441\u044f \u043d\u0435\u0432\u0435\u0440\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430, \u0447\u0442\u043e \u043a\u043e\u0434 \u0434\u043b\u044f 10-\u043e\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u0442\u0438\u043f double. \u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u0446\u0435\u043b\u044b\u0435. \u0417\u0430\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u0434 \u043d\u0430<\/p>\n<pre><code class=\"cpp\">std::string sufx[]{\"b\", \"Kb\", \"Mb\", \"Gb\", \"Tb\", \"Pb\", \"Eb\"}; void bytes_to_print(unsigned long long bytes) {     unsigned long long index{0};     unsigned long long fract;     while (1000 &lt;= bytes) {         fract = bytes;         bytes \/= 1000;         index++;     }     fract = fract % 1000 * 1000 \/ (1000 * 1000 \/ 100);     std::cout &lt;&lt; std::setw(4) &lt;&lt; bytes &lt;&lt; '.' &lt;&lt; std::setfill('0') &lt;&lt; std::setw(2) &lt;&lt; fract &lt;&lt; std::setfill(' ') &lt;&lt; ' ' &lt;&lt; sufx[index] &lt;&lt; '\\n'; }<\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u0434\u0435 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0446\u0435\u043b\u044b\u0439 \u0442\u0438\u043f \u043d\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u0438\u043f, \u0445\u043e\u0440\u043e\u0448\u043e. \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0446\u0438\u043a\u043b\u0430 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u043b\u0435\u043d\u0438\u0439? \u041c\u043e\u0436\u043d\u043e, \u043d\u043e \u0434\u043b\u044f 2-\u043e\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043e\u0442 \u043d\u0430 \u044d\u0442\u043e \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"cpp\">std::string sufx[]{\"b\", \"Kb\", \"Mb\", \"Gb\", \"Tb\", \"Pb\", \"Eb\"}; void bytes_to_print(unsigned long long bytes) {     unsigned long long index = bytes;     index |= index &gt;&gt; 1;     index |= index &gt;&gt; 2;     index |= index &gt;&gt; 4;     index |= index &gt;&gt; 8;     index |= index &gt;&gt; 16;     index |= index &gt;&gt; 32;     index &amp;= 0b0001'0000'0000'0100'0000'0001'0000'0000'0100'0000'0001'0000'0000'0100'0000'0000ull;     index += index &lt;&lt; 30;     index += (index &lt;&lt; 20) + (index &lt;&lt; 10);     index &gt;&gt;= 60;     unsigned long long fract = bytes;      bytes &gt;&gt;= index * 10;     fract &gt;&gt;= (index - 1) * 10;     fract = fract &amp; 0b11'1111'1111'00'0000'0000 \/ 10485;          std::cout &lt;&lt; std::setw(4) &lt;&lt; bytes &lt;&lt; '.' &lt;&lt; std::setfill('0') &lt;&lt; std::setw(2) &lt;&lt; fract &lt;&lt; std::setfill(' ') &lt;&lt; ' ' &lt;&lt; sufx[index] &lt;&lt; '\\n'; } <\/code><\/pre>\n<p>  \u0441\u0432\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <b>\u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432<\/b>. \u0412\u0430\u0448\u0438 \u043a\u043e\u043e\u0444\u0438\u0446\u0435\u043d\u0442\u044b \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0445, \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u0435 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 (\u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0447\u0438\u0441\u043b\u0430\u0445)<\/p>\n<pre><code class=\"python\">+-------------+---------------+-------------------+ | \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c    | \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f | \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f | +-------------+---------------+-------------------+ | Java 10-\u043e\u0433\u043e | 3.53c         | 9.43c             | | Java 2-\u043e\u0433\u043e  | 2.65c         | 7.43c             | | \u0421++ 10-\u043e\u0433\u043e  | 1.81c         | 3.29c             | | C++ 2-\u043e\u0433\u043e   | 1.12\u0441         | 1.24c             | +-------------+---------------+-------------------+<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u0434\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0441\u0443\u043f\u0435\u0440\u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u044d\u0448\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043e\u043a \u0438 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0448\u0438\u043d\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<h4>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u043a \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044e<\/h4>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/www.ozon.ru\/context\/detail\/id\/1927500\/\">\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f [\u0411\u0440\u0430\u0439\u0430\u043d \u0423. \u041a\u0435\u0440\u043d\u0438\u0433\u0430\u043d, \u0420\u043e\u0431 \u041f\u0430\u0439\u043a] The Practice of Programming<\/a> \u2014 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u043c\u044b\u0441\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430.<\/li>\n<li><a href=\"https:\/\/www.ozon.ru\/context\/detail\/id\/1039964\/\">\u0416\u0435\u043c\u0447\u0443\u0436\u0438\u043d\u044b \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 [\u0414. \u0411\u0435\u043d\u0442\u043b\u0438] Programming Pearls<\/a> \u2014 \u041a\u0430\u043a\u0438\u0435 \u043c\u043e\u0437\u0433\u043e\u043b\u043e\u043c\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442\u044c\u0441\u044f \u043a\u043e\u0433\u0434\u0430 \u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u0435\u0448\u044c \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b\u043c\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438(\u043f\u0435\u0440\u0432\u043e\u0435 \u0438\u0437\u0434\u0430\u043d\u0438\u0435).<\/li>\n<li><a href=\"https:\/\/www.ozon.ru\/context\/detail\/id\/5596946\/\">\u041f\u0438\u043e\u043d\u0435\u0440\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0414\u0438\u0430\u043b\u043e\u0433\u0438 \u0441 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f [\u0424\u0435\u0434\u0435\u0440\u0438\u043a\u043e \u0411\u044c\u044f\u043d\u043a\u0443\u0446\u0446\u0438, \u0428\u0435\u0439\u043d \u0423\u043e\u0440\u0434\u0435\u043d] Masterminds of Programming, Conversations with the Creators of Major Programming Languages<\/a> \u2014 \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u043e\u0432, \u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u043d\u0438\u0445 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435.<\/li>\n<\/ul>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/484082\/\"> https:\/\/habr.com\/ru\/post\/484082\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/484082\/\">\u042d\u0442\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 (<a href=\"https:\/\/habr.com\/ru\/post\/483864\/\">\u043f\u0435\u0440\u0432\u044b\u0439<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/484002\/\">\u0432\u0442\u043e\u0440\u043e\u0439<\/a>). \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0430 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435, \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0435\u0439 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0417\u0430\u0434\u0430\u0447\u0443 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0437 \u043d\u0430\u0448\u0443\u043c\u0435\u0432\u0448\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/478878\/\">\u00ab\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0447\u0438\u0441\u043b\u0430 (\u0431\u0430\u0439\u0442\u043e\u0432) \u0432 \u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0443 \u0421\u0418\u00bb<\/a>, \u043e\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439, \u0432 \u0441\u0438\u043b\u0443 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-297167","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=297167"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297167\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}