UVa 12250 – Language Detection
English, Spanish, German, French, Italian, and Russian are the six most prevalent languages in the European Union. The figure below shows the density of English speakers in various European countries. Each of these languages has 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."
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.
Languages | Translation of HELLO |
---|---|
中文 | HELLO |
Spanish | HOLA |
German | HALLO |
French | BONJOUR |
Italian | CIAO |
Russian | ZDRAVSTVUJTE |
Sample Inputs/Outputs
Sample Input(s) | Sample Output(s) |
---|---|
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. | 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. |
HELLO HOLA HALLO BONJOUR CIAO ZDRAVSTVUJTE # | Case 1: ENGLISH Case 2: SPANISH Case 3: GERMAN Case 4: FRENCH Case 5: ITALIAN Case 6: RUSSIAN |
Thought Process
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.
Sample Code-ZeroJudge A135: Language Detection
#include <iostream>
using namespace std;
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
int count = 1;
string str;
while (cin >> str)
{
if (str == "#") break;
else
{
if (str == "HELLO") cout << "Case " << count << ": ENGLISH" << endl;
else if (str == "HOLA") cout << "Case " << count << ": SPANISH" << endl;
else if (str == "HALLO") cout << "Case " << count << ": GERMAN" << endl;
else if (str == "BONJOUR") cout << "Case " << count << ": FRENCH" << endl;
else if (str == "CIAO") cout << "Case " << count << ": ITALIAN" << endl;
else if (str == "ZDRAVSTVUJTE") cout << "Case " << count << ": RUSSIAN" << endl;
else cout << "Case " << count << ": UNKNOWN" << endl;
count++;
}
}
}
//ZeroJudge A135
//Dr. SeanXD