{"id":320,"date":"2015-10-31T14:07:14","date_gmt":"2015-10-31T11:07:14","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=320"},"modified":"2015-12-15T16:26:46","modified_gmt":"2015-12-15T13:26:46","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","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=320","title":{"rendered":"\u0427\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c"},"content":{"rendered":"<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430:<\/strong> \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043a\u043e\u0440\u043f\u0443\u0441 \u044f\u0437\u044b\u043a\u0430 (\u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u044f\u0437\u044b\u043a\u0435) \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u0417\u043d\u0430\u043a\u0438 \u043f\u0440\u0435\u043f\u0438\u043d\u0430\u043d\u0438\u044f, \u0441\u043a\u043e\u0431\u043a\u0438, \u043a\u0430\u0432\u044b\u0447\u043a\u0438 \u0438 \u0447\u0438\u0441\u043b\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u044b. \u0421\u043b\u043e\u0432\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0432 \u0441\u0435\u0431\u0435 \u043d\u0435 \u0431\u0443\u043a\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/strong> <a href=\"http:\/\/ideone.com\/AIZAzB\">\u041a\u043e\u0434 \u043d\u0430 ideone<\/a><\/p>\n<pre class=\"lang:java decode:true\">import java.util.*;\r\nimport java.lang.*;\r\nimport java.text.*;\r\nimport java.io.*;\r\nimport java.util.regex.Pattern;\r\n\r\nclass Ideone\r\n{\r\n\tstatic HashMap&lt;String, Integer&gt; vocabulary = new HashMap&lt;String, Integer&gt;();\r\n\tstatic Scanner sc = new Scanner(System.in);\r\n\t\r\n\tpublic static boolean isEngLetter(char c){\r\n\t\treturn 'a' &lt;= c &amp;&amp; c &lt;= 'z' || 'A' &lt;= c &amp;&amp; c &lt;= 'Z'; \r\n\t}\r\n\t\r\n\tpublic static boolean isWord(String s){\r\n\t\tfor(int i = 0; i &lt; s.length(); i++){\r\n\t\t\tif(!(\t\r\n\t\t\t\t\tisEngLetter(s.charAt(i)) \t\t\t\t||\r\n\t\t\t\t\tCharacter.isDigit(s.charAt(i)) \t\t\t||\r\n\t\t\t\t\tPattern.matches(\"\\\\p{Punct}\", s)\r\n\t\t\t\t)\r\n\t\t\t)\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\tpublic static String toAlpha(String s){\r\n\t\treturn s.replaceAll(\"[^a-zA-Z]\",\"\");\r\n\t}\r\n\t\r\n\tpublic static void main (String[] args) throws java.lang.Exception\r\n\t{\r\n\t\twhile(sc.hasNext()){\r\n\t\t\tString s = sc.next();\r\n\t\t\tif(isWord(s)){\r\n\t\t\t\ts = toAlpha(s);\r\n\t\t\t\tif(!s.isEmpty()){\r\n\t\t\t\t\tvocabulary.put(s, vocabulary.containsKey(s) ? vocabulary.get(s) + 1 : 1);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tint sum = 0;\r\n\t\tfor(int value : vocabulary.values()){\r\n\t\t\tsum += value;\r\n\t\t}\r\n\t\tNumberFormat formatter = new DecimalFormat(\"#0.0000\");\r\n\t\tfor(String s : vocabulary.keySet()){\r\n\t\t\tSystem.out.println(s + \" \" + formatter.format((double)vocabulary.get(s)\/sum));\r\n\t\t}\r\n\t}\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430: \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043a\u043e\u0440\u043f\u0443\u0441 \u044f\u0437\u044b\u043a\u0430 (\u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u044f\u0437\u044b\u043a\u0435) \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u0417\u043d\u0430\u043a\u0438 \u043f\u0440\u0435\u043f\u0438\u043d\u0430\u043d\u0438\u044f, \u0441\u043a\u043e\u0431\u043a\u0438, \u043a\u0430\u0432\u044b\u0447\u043a\u0438 \u0438 \u0447\u0438\u0441\u043b\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u044b. \u0421\u043b\u043e\u0432\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0432 \u0441\u0435\u0431\u0435 \u043d\u0435 \u0431\u0443\u043a\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f: \u041a\u043e\u0434 \u043d\u0430 ideone import java.util.*; import java.lang.*; import java.text.*; import java.io.*; import java.util.regex.Pattern; class Ideone { static HashMap&lt;String, Integer&gt; vocabulary &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=320\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[40,41,39],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/320"}],"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\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=320"}],"version-history":[{"count":3,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/320\/revisions"}],"predecessor-version":[{"id":323,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/320\/revisions\/323"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}