#include <iostream> #include <string.h>using namespace std;bool check (char *str)//Determine if this is not a palindrome string. {int i = 0;int j = strlen (str) -1;while (i<j) {if (* (str+i)!=* (str+j)) return false;i++;j--;} return true;} void Get_str (char *str) {int n = strlen (str)-1; Char *p = new char[n+1];strcpy (p,str); int i = 0;int J; for (; i<n;i++) {p+=i;j = N-i;while (j>0)//Here J does not equal 0, one character is also a literal , but it is not necessary that the palindrome we seek here is a >=2 string. {* (p+j+1) = ' + '; if (check (p)) {cout<<p<< " "; Cout<<endl;} j--;} strcpy (P,STR);}} Thought is the beginning of the i=0, J=n began to//i, j--, know i>=j to i=0 the position of all the strings to find it again,//i++,j=n began to repeat the above operations.//.....//know I==n when the end, and outputs all palindrome strings evaluated. int main () {char s[]= "abaeedd"; Get_str (s); return 0;}
C + + asks all palindrome strings in a string and outputs the result (string manipulation)