判断是否为回文类型的字符串

 1 #include<iostream>
 2 using namespace std;
 3 
 4 bool Check_huiweng(const char* pstr, int n)
 5 {
 6     if (pstr == NULL)
 7         return false;
 8     char* front = const_cast<char*>(pstr);
 9     char* back = const_cast<char*>(pstr)+ n - 1;
10 
11     while (front < back)
12     {
13         if (*front != *back)
14         {
15             return false;
16         }
17         front++;
18         back--;
19     }
20     return true;
21 }
22 
23 void main()
24 {
25     char* str=(char*)malloc(sizeof(char));
26     cout << "plz enter a string:" << endl;
27     cin >> str;
28     int N = strlen(str);
29     bool result = Check_huiweng(str,N);
30     
31     system("pause");
32 }
原文地址:https://www.cnblogs.com/leejxyz/p/5534690.html