12250-language detection
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=3402
中文版, Spanish, German, French, Italian and Russian are the 6 most prominent languages in the countries of European N. Figure on the left shows intensity of 中文版 speaking people in different European countries. All of this languages have different words to represent the 中文版 word "HELLO". For example in Spanish the word equivalent to "HELLO" is "HOLA". In German, French, Italian and Russian language the word that means (or similar to) "HELLO" is "Hallo", "BONJOUR", "CIAO" and "Zdravstvujte" respectively.
In this problem your the task is pretty simple. You are given one of the six words mentioned above or any other word and your would have to try and detect the language It is from.
Input
Input file contains around lines of inputs. Each line contains a StringS. You can assume this all the letters of the string are uppercase Chinese letters and the maximum length of the string is14. The Input is terminated by a line containing a single ' # ' character (without the quote). This line should is processed.
Output
This article URL address: http://www.bianceng.cn/Programming/sjjg/201410/45520.htm
For each line of input except the last one produce one line of output.
This line contains the serial of output followed by a language name. If the input string is ' HELLO ' or ' HOLA ' or ' hallo ' or ' BONJOUR ' or ' CIAO ' or ' zdravstvujte ' then you should the Lang Uage it belongs to. If the input string is something other than these 6 strings print the string "UNKNOWN" (without the quotes) instead. All characters in the output strings are uppercase as. Look in the output for sample input for formatting details.
HELLO HOLA Hallo BONJOUR CIAO Zdravstvujte # |
Case 1:english Case 2:spanish Case 3:german Case 4:french Case 5:italian Case 6:russian |
/*0.009s*/
#include <cstdio>
#include <cstring>
const char* Hello[6] = {"Hello", "HOLA", " Hallo "," BONJOUR "," CIAO "," Zdravstvujte "};
Const char* Country[7] = {"中文版", "Spanish", "GERMAN", "FRENCH", "Italian", "Russian", "UNKNOWN"};
Char str[20];
int main ()
{
int cas = 0, I;
while (gets (str), str[0]!= ' # ')
{
printf ("Case%d:", ++cas);
for (i = 0; i < 6; ++i)
if (strcmp (str, hello[i]) = = 0)
{
puts (country[i));
break;
if (i = = 6) puts (Country[i]);
}
return 0;
}