Codeforces Round #607 (Div. 2) 1281A

原题链接

Codeforces Problemset 1281A

题目大意

给你一个以_代替单词间空格的句子,要求你根据后缀判断这个句子是哪种语言。

解题思路

因为各个语言后缀的末尾字母相异,直接根据末尾字母判断即可。

代码

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args){
		solution s = new solution();
		s.solve();
		s.close();
	}
}

interface IO{
	Scanner in = new Scanner(new BufferedInputStream(System.in));
	PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
}

class solution implements IO{
	
	final int MAXN = (int) 1e3+5;
	
	void solve(){
		int n = in.nextInt();
		while(n-- != 0){
			String s = in.next();
			int len = s.length();
			switch(s.charAt(len - 1)){
				case 'o':out.println("FILIPINO");break;
				case 'u':out.println("JAPANESE");break;
				case 'a':out.println("KOREAN");break;
			}
		}
	}
	
	void close(){
		in.close();
		out.close();
	}
}

你可能感兴趣的:(题解,&,代码)