您的位置:首页 > 其它

2017上海市高校程序设计邀请赛_L

2017-07-04 17:39 246 查看
problem list

L 语言辨别



观察题

发现中文拼音里面最长的是类似于 zhuang 的,即最长6个字符

对于英文来说,查找特定词,查找介词、冠词和不定冠词为主:is,are,and,in,on……

然后剩下的就判定是日文

#include <bits/stdc++.h>
using namespace std;
typedef long long           LL ;
typedef unsigned long long ULL ;
const int    maxn = 1000 + 10  ;
const int    inf  = 0x3f3f3f3f ;
const int    npos = -1         ;
const double eps  = 1e-20      ;

std::string str;
int sz, cnt;
int main(){
// freopen("in.txt","r",stdin);
// freopen("out.txt","+aw",stdout);
int chi=0, jap=0, eng=0, maxcnt=0;
while(getline(cin,str)){
sz=str.size();
cnt=0;
for(int i=0;i<sz;i++){
if(' '==str[i]){
maxcnt=max(maxcnt,cnt);
cnt=0;
}else{
cnt++;
}
}
if(std::string::npos!=str.find(" is ")){
eng=1;
}
if(std::string::npos!=str.find(" are ")){
eng=1;
}
if(std::string::npos!=str.find(" and ")){
eng=1;
}
if(std::string::npos!=str.find(" in ")){
eng=1;
}
if(std::string::npos!=str.find(" on ")){
eng=1;
}
}
if(maxcnt<=6){
chi=1;
}
if(eng){
cout<<"English"<<endl;
}else if(chi){
cout<<"Chinese"<<endl;
}else{
cout<<"Japanese"<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐