本文主要是介绍codeforces 41A(Translation) Java,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
水题走一波,记住字符串反转函数的使用。
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;/*** 题意:输入两个单词,如果它俩互为反转(即code==edoc),则输出 YES,否则输出 NO*/
public class Main {public static void main(String[] args) throws IOException {Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));String wordT;String wordS;while (in.hasNext()) {wordT = in.next();wordS = in.next();out.println(wordS.equals(new StringBuilder(wordT).reverse().toString()) ? "YES" : "NO");}out.flush();}
}
这篇关于codeforces 41A(Translation) Java的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!