{"id":55,"date":"2015-07-10T08:20:33","date_gmt":"2015-07-10T05:20:33","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=55"},"modified":"2015-07-17T09:44:31","modified_gmt":"2015-07-17T06:44:31","slug":"55","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=55","title":{"rendered":"\u0421omparison"},"content":{"rendered":"<h1>Task<\/h1>\n<p>In three-digit number find which digit is bigger &#8212; the most right or the most left. If all digits are equal, enter as an result the word<strong> &#171;equals&#187;.<\/strong><\/p>\n<p>Similar task to this can be found <a href=\"http:\/\/www.e-olymp.com\/ru\/problems\/903\" target=\"_blank\">here<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h1>Tests<\/h1>\n<p>Try to find all possible combinations distributed by growing. Should be not less than 13 combinations.<\/p>\n<table>\n<tbody>\n<tr>\n<td>Input<\/td>\n<td>Output<\/td>\n<\/tr>\n<tr>\n<td>555<\/td>\n<td>\u00a0equals<\/td>\n<\/tr>\n<tr>\n<td>554<\/td>\n<td>\u00a05<\/td>\n<\/tr>\n<tr>\n<td>545<\/td>\n<td>\u00a0equals<\/td>\n<\/tr>\n<tr>\n<td>455<\/td>\n<td>\u00a05<\/td>\n<\/tr>\n<tr>\n<td>557<\/td>\n<td>\u00a07<\/td>\n<\/tr>\n<tr>\n<td>575<\/td>\n<td>\u00a0equals<\/td>\n<\/tr>\n<tr>\n<td>755<\/td>\n<td>\u00a07<\/td>\n<\/tr>\n<tr>\n<td>321<\/td>\n<td>\u00a03<\/td>\n<\/tr>\n<tr>\n<td>312<\/td>\n<td>\u00a03<\/td>\n<\/tr>\n<tr>\n<td>231<\/td>\n<td>\u00a03<\/td>\n<\/tr>\n<tr>\n<td>213<\/td>\n<td>\u00a03<\/td>\n<\/tr>\n<tr>\n<td>123<\/td>\n<td>\u00a03<\/td>\n<\/tr>\n<tr>\n<td>132<\/td>\n<td>\u00a03<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>Solution<\/h1>\n<p>With &#171;if&#187; statement:<\/p>\n<pre class=\"lang:java decode:true\" title=\"http:\/\/ideone.com\/jlFK3x\">import java.util.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\n \r\nclass Main{\r\n\tpublic static void main (String[] args) throws java.lang.Exception {\r\n\t\tScanner s = new Scanner(System.in);\t\r\n\t\tint x = s.nextInt();\r\n\t\tint y = x \/ 100;\r\n\t\tint z =  x % 10;\r\n\t\t\t\r\n\t\tif(y &gt; z){\r\n\t\t\tSystem.out.println(y);\r\n\t\t} else if(y &lt; z ){\r\n\t\t\tSystem.out.println(z);\r\n\t\t} else{\r\n\t\t\tSystem.out.println(\"equals\");\r\n\t\t}\r\n\t\ts.close();\r\n\t}\r\n}\r\n<\/pre>\n<h1>Code refactoring<\/h1>\n<pre class=\"lang:java decode:true \" title=\"http:\/\/ideone.com\/fork\/jlFK3x\">import java.util.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\n \r\nclass Main{\r\n\tpublic static void main (String[] args) throws java.lang.Exception {\r\n\t\tScanner s = new Scanner(System.in);\t\r\n\t\tint x = s.nextInt();\r\n\t\tint y = x \/ 100;\r\n\t\tint z =  x % 10;\r\n\t\r\n\t\tSystem.out.println(y &gt; z? y : y &lt; z? z : \"equals\");\r\n\t\t\r\n\t\ts.close();\r\n\t}\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Task In three-digit number find which digit is bigger &#8212; the most right or the most left. If all digits are equal, enter as an result the word &#171;equals&#187;. Similar task to this can be found here. &nbsp; Tests Try to find all possible combinations distributed by growing. Should be not less than 13 combinations. &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=55\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":56,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[15,17,16,18],"jetpack_featured_media_url":"https:\/\/java.mazurok.com\/wp-content\/uploads\/moda-dlya-nizkikh-i-polnykh-20141.jpg","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/55"}],"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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=55"}],"version-history":[{"count":17,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/55\/revisions\/105"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/media\/56"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}