将给定字符串分割成多个小的回文串

20170827_将给定字符串分割成多个小的回文串


//将给定字符串分割成多个小的回文串
/* Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s ="aab",
Return
  [
    ["aa","b"],
    ["a","a","b"]
  ]
*/
#include
#include
#include
#include
#include
#include
using namespace std;

class Solution
{
public:
	//判断字符串s是不是回文串
	bool isPalindrome(string s)
	{
		int sLen=s.size();
		if(sLen<1)
			return false;
		int i=0, j=sLen-1;
		while(i> &res, vector &temp)
	{
		int sLen=s.size();
		if(sLen<1)
		{
			res.push_back(temp);
			return;
		}
		//判断s从0位置开始字符串大小为1,...,s.size()的子串是否是回文,
		//temp为所有可能字符串的访问路径,只保存回文到res。
		for(int i=0; i> partition(string s)
    {
		vector> res;
		vector temp;
		partition_core(s,res,temp);
		//输出有坑啊:对res做一些调整才能AC

		return res;
	}
};

int main(void)
{
	string str;
	cin>>str;
	class Solution object;
	vector> res;
	res=object.partition(str);
	for(auto row:res)
	{
		for(auto col:row)
			cout<




你可能感兴趣的:(C++字符串专栏)