{"id":513,"date":"2015-12-21T00:12:19","date_gmt":"2015-12-20T21:12:19","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=513"},"modified":"2015-12-28T01:16:55","modified_gmt":"2015-12-27T22:16:55","slug":"%d1%87%d0%b0%d1%81%d1%82%d0%be%d1%82%d0%bd%d1%8b%d0%b9-%d1%81%d0%bb%d0%be%d0%b2%d0%b0%d1%80%d1%8c-2","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=513","title":{"rendered":"\u0427\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c"},"content":{"rendered":"<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f &#171;\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c&#187; \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A7%D0%B0%D1%81%D1%82%D0%BE%D1%82%D0%BD%D1%8B%D0%B9_%D1%81%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8C\">\u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/a>.<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u0441\u0432\u043e\u0435\u043c <a href=\"http:\/\/java.mazurok.com\/new\/%D0%B0%D0%B2%D0%BB-%D0%B4%D0%B5%D1%80%D0%B5%D0%B2%D0%BE.html\">\u0410\u0412\u041b-\u0434\u0435\u0440\u0435\u0432\u0435<\/a>.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u0441\u043b\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044e <a href=\"http:\/\/java.mazurok.com\/word-of-week\/java-collections-framework-map\">\u0437\u0430\u0434\u0430\u0447\u0438 1<\/a>. \u041f\u043e\u0442\u043e\u043c\u0443, \u043d\u0430\u0434\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a map \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0435\u0435 \u043a\u043b\u044e\u0447 -&gt; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u0410\u0412\u041b-\u0434\u0435\u0440\u0435\u0432\u043e \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0440\u043e\u0434\u0435 \u0441\u0445\u043e\u0436\u0435 \u0441 map, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u041f\u0440\u0430\u0432\u0434\u0430 \u043e\u043d\u043e \u043d\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0438\u0440\u0443\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0438\u0440\u0443\u0435\u0442 map. \u0420\u0430\u0437\u0431\u0438\u0432 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0441\u043b\u043e\u0432\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0438\u0445 \u0432 \u0434\u0435\u0440\u0435\u0432\u043e \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0445 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445. \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u043c\u0435\u0435\u0442 \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 &#8212; \u044d\u0442\u043e \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0443 \u0432\u044b\u0434\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0435\u0433\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435, \u0442\u043e \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0410\u0412\u041b-\u0434\u0435\u0440\u0435\u0432\u0430.<\/p>\n<table style=\"height: 549px\" width=\"685\">\n<tbody>\n<tr>\n<td>#include &lt;iostream&gt;<br \/>\nusing namespace std;int main() {for( int i = 0; i &lt; 10; i++ )<br \/>\n{<br \/>\nif( i % 2 == 0 )<br \/>\n{<br \/>\ncout &lt;&lt; \u201cEven\u201d &lt;&lt; endl;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\ncout &lt;&lt; \u201cOdd\u201d &lt;&lt; endl;<br \/>\n}<br \/>\n}<br \/>\nreturn 0;<br \/>\n}%EOF%<\/p>\n<p>&nbsp;<\/td>\n<td>0 3 0.1111111111111111<br \/>\n10 1 0.037037037037037035<br \/>\n2 1 0.037037037037037035<br \/>\nEven 1 0.037037037037037035<br \/>\nOdd 1 0.037037037037037035<br \/>\ncout 2 0.07407407407407407<br \/>\nelse 1 0.037037037037037035<br \/>\nendl 2 0.07407407407407407<br \/>\nfor 1 0.037037037037037035<br \/>\ni 4 0.14814814814814814<br \/>\nif 1 0.037037037037037035<br \/>\ninclude 1 0.037037037037037035<br \/>\nint 2 0.07407407407407407<br \/>\niostream 1 0.037037037037037035<br \/>\nmain 1 0.037037037037037035<br \/>\nnamespace 1 0.037037037037037035<br \/>\nreturn 1 0.037037037037037035<br \/>\nstd 1 0.037037037037037035<br \/>\nusing 1 0.037037037037037035<\/td>\n<\/tr>\n<tr>\n<td>aaa for bbb aaa for if<br \/>\n%EOF%<\/td>\n<td>aaa 2 0.3333333333333333<br \/>\nbbb 1 0.16666666666666666<br \/>\nfor 2 0.3333333333333333<br \/>\nif 1 0.16666666666666666<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre class=\"lang:java decode:true \">import java.util.Scanner;\r\nimport java.util.StringTokenizer;\r\n\r\n\/**\r\n * Created by green on 20.12.15.\r\n *\/\r\nclass Vocabular{\r\n    private AVL&lt;String, Statistic&gt; voc;\r\n    int gloablCount = 0;\r\n    public class Statistic{\r\n        private int Count;\r\n        private double Percent;\r\n        Statistic(){\r\n            Count = 1;\r\n            Percent = 0;\r\n        }\r\n        public int getCount(){\r\n            return Count;\r\n        }\r\n        public double getPercent(){\r\n            return Percent;\r\n        }\r\n\r\n    }\r\n    public Vocabular(String text, String delimiters){\r\n        voc = new AVL();\r\n        StringTokenizer st = new StringTokenizer(text, delimiters);\r\n        while (st.hasMoreTokens()){\r\n            String key = st.nextToken();\r\n            Statistic value = voc.get(key);\r\n            if (null != value){\r\n                value.Count++;\r\n                voc.add(key, value);\r\n            }else{\r\n                value = new Statistic();\r\n                voc.add(key, value);\r\n            }\r\n            gloablCount++;\r\n        }\r\n        for(AVL&lt;String, Statistic&gt;.Node e = voc.getFirstNode(); e != null; e = e.next()){\r\n            e.value.Percent = (double)e.value.Count\/gloablCount;\r\n        }\r\n    }\r\n\r\n    public AVL&lt;String, Statistic&gt;.Node getFirstNode(){\r\n        return voc.getFirstNode();\r\n    }\r\n\r\n    public double getValue(String key){\r\n        Statistic v = voc.get(key);\r\n        if(v == null) return 0;\r\n        else return v.Percent;\r\n    }\r\n}\r\n\r\n\r\n\r\npublic class Vocabulary {\r\n    public static void main(String[] args){\r\n        String text = \"\";\r\n        Scanner in = new Scanner(System.in);\r\n        for(;;){\r\n            if(!in.hasNextLine()) break;\r\n            String inputLine = in.nextLine();\r\n            if(inputLine == null || inputLine.equals(\"%EOF%\")) break;\r\n            text = text + inputLine + \"\\n\";\r\n        }\r\n        in.close();\r\n        if(text.isEmpty()){\r\n            System.out.println(\"*** Empty text ****\");\r\n            return;\r\n        }\r\n        Vocabular voc = new Vocabular(text, \" ?.,;:-+\\n\\t{}[]=()&lt;&gt;*&amp;%$#@\\\"\\'\u201c\u201d`~!\");\r\n        for(AVL&lt;String, Vocabular.Statistic&gt;.Node e = voc.getFirstNode(); e != null; e = e.next()){\r\n            System.out.println(e.key+\" \"+e.value.getCount()+\" \"+e.value.getPercent());\r\n        }\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/ideone.com\/4wurcy\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 ideone.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f &#171;\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c&#187; \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u0410\u0412\u041b-\u0434\u0435\u0440\u0435\u0432\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u0441\u043b\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 1. \u041f\u043e\u0442\u043e\u043c\u0443, \u043d\u0430\u0434\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a map \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0435\u0435 \u043a\u043b\u044e\u0447 -&gt; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u0410\u0412\u041b-\u0434\u0435\u0440\u0435\u0432\u043e \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0440\u043e\u0434\u0435 \u0441\u0445\u043e\u0436\u0435 \u0441 map, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u041f\u0440\u0430\u0432\u0434\u0430 \u043e\u043d\u043e \u043d\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0438\u0440\u0443\u0435\u0442 \u043d\u0438 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=513\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":33,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/513"}],"collection":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=513"}],"version-history":[{"count":9,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/513\/revisions"}],"predecessor-version":[{"id":543,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/513\/revisions\/543"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}