#34768: 用Array


laquum (laquum)

學校 : 不指定學校
編號 : 229494
來源 : [114.43.59.45]
最後登入時間 :
2023-06-19 16:18:54
a135. 12250 - Language Detection -- UVa12250 | From: [114.43.9.211] | 發表日期 : 2023-04-14 21:40

#include <iostream>
#include <string>
using namespace std;

string nations[7] = {"ENGLISH", "SPANISH", "GERMAN", "FRENCH", "ITALIAN", "RUSSIAN", "UNKNOWN"};
string greets[6] = {"HELLO", "HOLA", "HALLO" , "BONJOUR" , "CIAO", "ZDRAVSTVUJTE"};
int main()
{
    string s;
    
    int k = 0;
    while(cin >> s)
    {
        if(s[0] == '#')
            break;
        int i = 0;
        for(; i < 6; i++)
        {
            if(s.compare(greets[i]) == 0)
                break;
        }
        
        cout << "Case " << ++k << ": " << nations[i] << '\n';
    }
    return 0;
}

 
ZeroJudge Forum