mport java.io.*;
import java.util.*;
public class Around0521 {
public static void main(String args[]) throws IOException{
FileReader inputjerry=new FileReader("940301.SM");
BufferedReader binputjerry=new BufferedReader(inputjerry);
// System.out.print("(迴文判斷)請輸入字母或數字:");
String s1=binputjerry.readLine();
String s2="";
for (int i=s1.length();i>0;i--){
char ch =s1.charAt(i-1);
s2=s2+ch;
}
if (s1.equals(s2)) System.out.println(s1+" is a palindrome"); //如果s1=s2
else System.out.println(s1+" is not a palindrome");
FileWriter outputjerry=new FileWriter("940301.T01");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
if (s1.equals(s2)) boutputjerry.write(String.valueOf(s1+" is a palindrome"));
else boutputjerry.write(String.valueOf(s1+" is not a palindrome"));
boutputjerry.flush();
boutputjerry.close();
}
}
沒有留言:
張貼留言