{"id":145,"date":"2024-04-26T14:38:33","date_gmt":"2024-04-26T06:38:33","guid":{"rendered":"https:\/\/seanxd.com\/?p=145"},"modified":"2024-04-26T14:38:35","modified_gmt":"2024-04-26T06:38:35","slug":"zerojudge-a135","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-a135\/","title":{"rendered":"ZeroJudge A135: Language Detection"},"content":{"rendered":"<h3 class=\"wp-block-heading\">UVa 12250 \u2013 Language Detection<\/h3>\n\n\n\n<p class=\"\">English, Spanish, German, French, Italian, and Russian are the six most prevalent languages \u200b\u200bin the European Union. The figure below shows the density of English speakers in various European countries. Each of these languages \u200b\u200bhas different words to express the English word \"HELLO.\" For example, the equivalent word for \"HELLO\" in Spanish is \"HOLA,\" in German, it's \"HALLO,\" in French, it's \"BONJOUR,\" in Italian, it's \"CIAO,\" and in Russian, it's \"ZDRAVSTVUJTE.\"<\/p>\n\n\n\n<p class=\"\">Your task in this problem is quite simple. Given one of the words mentioned above or any other word, you need to identify which language it belongs to.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full nfd-wb-animate nfd-wb-zoom-in-short\"><img decoding=\"async\" width=\"299\" height=\"306\" loading=\"lazy\" src=\"https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Language-Detection.gif\" alt=\"ZeroJudge A135: Language Detection\u82f1\u8a9e\u4eba\u53e3\u65bc\u6b50\u6d32\u5404\u570b\u5bc6\u5ea6\" class=\"wp-image-146\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short nfd-delay-50\"><table class=\"has-fixed-layout\"><thead><tr><th>Languages<\/th><th>Translation of HELLO<\/th><\/tr><\/thead><tbody><tr><td>\u4e2d\u6587<\/td><td>HELLO<\/td><\/tr><tr><td>Spanish<\/td><td>HOLA<\/td><\/tr><tr><td>German<\/td><td>HALLO<\/td><\/tr><tr><td>French<\/td><td>BONJOUR<\/td><\/tr><tr><td>Italian<\/td><td>CIAO<\/td><\/tr><tr><td>Russian<\/td><td>ZDRAVSTVUJTE<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Hello Translation Chart<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Inputs\/Outputs<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short nfd-delay-150\"><table class=\"has-fixed-layout\"><thead><tr><th>Sample Input(s)<\/th><th>Sample Output(s)<\/th><\/tr><\/thead><tbody><tr><td class=\"translation-block\">The input consists of about 2000 lines. Each line contains a string S. You can assume that all letters are uppercase English letters, and the maximum length of the string is 14. The input is terminated by a line containing only \"#\" which does not need to be processed.<\/td><td class=\"translation-block\">Except for the last line, there should be one line of output for each input line. This output line should contain the output serial number and the name of the language. If the input string is not one of the specified words, print \"UNKNOWN.\" All output strings should be in uppercase.<\/td><\/tr><tr><td>HELLO<br>HOLA<br>HALLO<br>BONJOUR<br>CIAO<br>ZDRAVSTVUJTE<br>#<\/td><td>Case  1:  ENGLISH<br>Case  2:  SPANISH<br>Case  3:  GERMAN<br>Case  4:  FRENCH<br>Case  5:  ITALIAN<br>Case  6:  RUSSIAN<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Thought Process<\/h2>\n\n\n\n<p class=\"translation-block\">You can use if statements to determine the language of the input string. You can also use an integer variable outside the EOF loop to keep track of which case you are currently processing.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=a135\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge A135: Language Detection<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-300\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n  cin.sync_with_stdio(0);\n  cin.tie(0);\n  int count = 1;\n  string str;\n  while (cin &gt;&gt; str)\n    {\n      if (str == &quot;#&quot;) break;\n      else\n      {\n        if (str == &quot;HELLO&quot;) cout &lt;&lt; &quot;Case &quot; &lt;&lt; count &lt;&lt; &quot;: ENGLISH&quot; &lt;&lt; endl;\n        else if (str == &quot;HOLA&quot;) cout &lt;&lt; &quot;Case &quot; &lt;&lt; count &lt;&lt; &quot;: SPANISH&quot; &lt;&lt; endl;\n        else if (str == &quot;HALLO&quot;) cout &lt;&lt; &quot;Case &quot; &lt;&lt; count &lt;&lt; &quot;: GERMAN&quot; &lt;&lt; endl;\n        else if (str == &quot;BONJOUR&quot;) cout &lt;&lt; &quot;Case &quot; &lt;&lt; count &lt;&lt; &quot;: FRENCH&quot; &lt;&lt; endl;\n        else if (str == &quot;CIAO&quot;) cout &lt;&lt; &quot;Case &quot; &lt;&lt; count &lt;&lt; &quot;: ITALIAN&quot; &lt;&lt; endl;\n        else if (str == &quot;ZDRAVSTVUJTE&quot;) cout &lt;&lt; &quot;Case &quot; &lt;&lt; count &lt;&lt; &quot;: RUSSIAN&quot; &lt;&lt; endl;\n        else cout &lt;&lt; &quot;Case &quot; &lt;&lt; count &lt;&lt; &quot;: UNKNOWN&quot; &lt;&lt; endl;\n        count++;\n      }\n    }\n}\n\n\/\/ZeroJudge A135\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 12250 &#8211; Language Detection \u82f1\u6587\u3001\u897f\u73ed\u7259\u6587\u3001\u5fb7\u6587\u3001\u6cd5\u6587\u3001\u7fa9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[18],"tags":[8,11],"class_list":["post-145","post","type-post","status-publish","format-standard","hentry","category-uva","tag-8","tag-11"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=145"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/145\/revisions"}],"predecessor-version":[{"id":147,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/145\/revisions\/147"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}