^&^ Code 1#include<iostream> 2 3using namespace std; 4 5bool huiwen(char* str) 6{ 7 char* end=str; 8 char* first=str; 9 int temp=strlen(str)/2+1;10 while(*end++!='\0')11 NULL;12 end--; //point to the char '\0'13 while(temp-->0)14 {15 if(*first++!=*(--end)) //--end in order to point to the char before '\0'16 return false;17 }18 return true;19}2021bool huiwen2(char* str)22{23 int length=strlen(str);24 for(int i=0; i<length; i++)25 if(*(str+i)!=*(str+length-i-1))26 return false;27 return true;28}29int main()30{31 char* str="hongshenggnehsgnoh";32 cout<<huiwen(str)<<endl;33 cout<<huiwen2(str)<<endl;34 return 0;35}36 转载于:https://www.cnblogs.com/lihongsheng0217/archive/2008/11/16/1334435.html