import java.io.*;
public class around {
public static void main(String args[]) throws IOException{
BufferedReader buf =new BufferedReader(new InputStreamReader(System.in));
System.out.print("(迴文判斷)請輸入字母或數字:");
String s1=buf.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+"是迴文");
else System.out.println(s1+"非迴文");
}
}
--------------------Configuration:
(迴文判斷)請輸入字母或數字:12345654321
12345654321是迴文
Process completed.
全站熱搜
留言列表