首页 > 其他 > 详细

回文字符串

时间:2017-06-24 22:20:27      阅读:317      评论:0      收藏:0      [点我收藏+]
import java.util.Scanner;

/**
 * 给出一个长度不超过1000的字符串,判断它是不是回文(顺读,逆读均相同)的
 * @author kif
 *
 */
public class Palindrome {
	
	public static void judge(String str){
		String sOne = str.substring(0, str.length()/2);
		System.out.println(sOne.startsWith(new StringBuffer(str).reverse().substring(0, str.length()/2)));
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		String str = input.nextLine();
		Palindrome.judge(str);
		input.close();
	}

}

 

回文字符串

原文:http://www.cnblogs.com/kongkongFabian/p/7074626.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!